Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
5

My filter is not working, can someone help?

Asked by 9 years ago

Here is the script

Filtered = {"Word1","Word2","Word3"}
game.Players.PlayerAdded:connect(function(p)
p.Chatted:connect(function(msg)
for i,v in pairs(Filtered) do
if msg == v then
p:Kick()
end
end
end)
end)

Whenever a player says a word in the Filtered table it should kick them. But it only works if they say the word in it so it cannot detect it in a sentence D: Please help!

1
In advance: Thanks! fireboltofdeath 635 — 9y

1 answer

Log in to vote
2
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
9 years ago

For this script, you're going to want to use the find method. And I would also advise in using the lower method to match a word more easily. So, I have edited your script below, it should detect for the words in the wordlist whether the message was in caps or all lower case letters.

Filtered = {"Word1","Word2","Word3"}
game.Players.PlayerAdded:connect(function(p)
p.Chatted:connect(function(msg)
for i,v in pairs(Filtered) do
if string.find(msg:lower(), v:lower()) then
p:Kick()
end
end
end)
end)
1
Yes, yes. I know the lower method and was expecting to use that and I could never get find to work for some reason so I will test this, thanks! fireboltofdeath 635 — 9y
0
Thanks! fireboltofdeath 635 — 9y
0
you can also use string.lower(msg), just FYI trogyssy 221 — 9y
0
I know that trog, I just find it easier to use the shortened method rather than the longer one. M39a9am3R 3210 — 9y
Ad

Answer this question