Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My filter is not working, can someone help?

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 comment

1

In advance: Thanks!

1 answer

✓ Accepted answer

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)

4 comments

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!

0

Thanks!

0

you can also use string.lower(msg), just FYI

0

I know that trog, I just find it easier to use the shortened method rather than the longer one.

This discussion is preserved as it was. New answers, comments, and votes are closed.