Code:
on *:text:*:#: {
  if ($nick isop $chan) || ($nick isvoice $chan) { halt }
  if (LOL iswm $1-) {
    if (%r. [ $+ [ $nick ] $+ . $+ [ $chan ] ] == $null) {
      set -u30 %r. [ $+ [ $nick ] $+ . $+ [ $chan ] ] 1
      set -u30 %r.text. [ $+ [ $nick ] $+ . $+ [ $chan ] ] $1-
    }
    %rps = %r. [ $+ [ $nick ] $+ . $+ [ $chan ] ]
    %rpt = %r.text. [ $+ [ $nick ] $+ . $+ [ $chan ] ]
    if (%rpt == $1-) {
      inc %r. [ $+ [ $nick ] $+ . $+ [ $chan ] ]
      if (%rps >= 2) { kick # $nick REASON: You said a bad word! }
      if (%rps >= 3) {
      ban -u15 # $address($nick,2) | kick # $nick REASON: you said a bad word again! }
    }
  }
}


you had:
on *:text:*:#: { which has the script react to all channels you are in, for ANY text (the * is a wildcard that matches anything)

then you have:
if ($nick !isop $chan) && ($nick !isvoice #) {
the # should have been $chan. Also I changed it to be if they are op OR voice the script stops, if they are not op or voice it then checks for the word "LOL" I used this as I do not know what words you want to restrict.
you can add more words like this:
if (LOL iswm $1-) || (foobar iswm $1-) {
-
I have not tested this but I believe it should work.