You are trying to execute two while loops at the same time.

Code:
 
on ^*:notice:*:?: {
  if (!$istok(ChanServ NickServ MemoServ,$nick,32)) && $hget(BadWords,0) {
    var %cnt = 1
    while (%cnt <= $hget(BadWords,0).item) {
      if $hget(BadWords,%cnt).item isin $1- {
        spamdetect $nick
        haltdef
      }
      else {        inc %cnt      }
    }
  }
}

alias spamdetect {
  var %a = 1
  while $comchan($1,%a).op {
    ban -ku3600 $v1 $1 2 14Private Offensive Language
  }
  inc %a
}


First your !$istok line is not evaluating properly... change it to this:

Code:
  var %oknames = ChanServ NickServ MemoServ
  if ($nick !isin %oknames) && $hget(BadWords,0) {


Then you will have to ban and kick the nick in the first loop. You have spamdetect $nick as a second loop that would be trying to operate while the first one is still working, this will freeze your mIRC.

Code:
 on ^*:notice:*:?: {
  var %oknames = ChanServ NickServ MemoServ
  if ($nick !isin %oknames) && $hget(BadWords,0) {
    var %cnt = 1
    while (%cnt <= $hget(BadWords,0).item) {
      if $hget(BadWords,%cnt).item isin $1- {
        if ($me isop $chan) {
        /ban -ku3600 $chan $nick
        halt
        }
      }
      else inc %cnt 
    }
  }
}
 




Scripto ---- Life is about the relationships. The correct code being: $replace($them,$you,$me)