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

Why does my kick on chat script doesn't work? Making a family friendly game.

Asked by 6 years ago

Hi there, back with another kick script needing help.

So this time I need help with this, why does my "kick on chat" script doesn't work?

01local canKick = {"LocalPlayer"}
02 
03game.Players.PlayerAdded:Connect(function(plr)
04    for _, c in pairs(canKick) do
05        if plr.Name == c then
06            plr.Chatted:Connect(function(msg)
07                if string.sub(msg,1,5) == "Damn" then
08                    local pl = game.Players:FindFirstChild(string.sub(msg,7))
09                    if pl then
10                        pl:Kick("Kicked for bad language.")
11                    end
12                end
13            end)
14        end
15    end
16end)

Just wanting help with this, just making a family friendly chat game! ;)

Thanks!

0
is this a server script User#23365 30 — 6y
0
What if they write the swear word somewhere else in their message? Also, why do you not use Roblox's default chat filter? User#25115 0 — 6y
0
Why? People can counter it dude. Seen people saying words such as Phak etc. That BYPASSES Roblox's horrible tagged chat filter anyways. LOL. CR_BEAST123 22 — 6y
0
If an API made by professionals is bypassed then I don't see how you can do any better https://developer.roblox.com/articles/Text-and-Chat-Filtering xPolarium 1388 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

You would want to use other string methods so they can't bypass the filter so easily. The find and lower keywords would work good for this case.

01local Kickable = {"ThatPreston"}
02 
03game.Players.PlayerAdded:Connect(function(Player)
04    for _, Entry in pairs(Kickable) do
05        if Entry == Player.Name then
06            Player.Chatted:Connect(function(Message)
07                Message = string.lower(Message) -- > make the message lowercase
08                if string.find(Message, "damn") then -- > check if damn is in the message
09                    Player:Kick("Kicked for bad language.") -- > kick the player
10                end
11            end)
12        break
13        end
14    end
15end)

You'd want to put this script in ServerScriptService, ideally. You didn't clarify where or what your previous script was, but you'd typically want something like this on the server, in a normal script. I hope this helps! Good luck!

Ad

Answer this question