Just a few remarks:
-> /var %something = value don't forget the = unless the %var is the result of a $identifier
-> a while loop with as only function a return??

Well, I'd do it like this, but then again, I'm addicted to regex...

Code:
on *:TEXT:*:#channelnamehere: {
  if ($regex($1-,/([color:green][a-z][/color])[color:blue]\1\1\1[/color]/ig) >= [color:red]2[/color]) {
    ban -ku3600 $chan $nick 5 You'rrrre outttt!!!!
  }
}


[a-z] means only check a to z for doubles, you can make it . (yes, one dot) to ban on ALL characters or [a-z_:!?'"] to match letters and some special signs.

The \1\1\1 means 4 repeats of the same character are counted, you can add or remove \1's for other numbers...

The 2 is how many different occasions in the same line are needed before action is taken. This is to prevent accidental banning if there happens to be a word with 3 same consecutive letters in your language smile