On on nick event doesn't have a #/$chan. Something like that would return $Null. you will have to use $comchan. the simplest script you can use is $comchan($newnick,1). However i would suggest a loop:

var %x = 1
while ($comchan($newnick,%x)) {
ban -k $v1 $newnick badnick
inc %x
}


Best Regards,

evol