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?

local canKick = {"LocalPlayer"}

game.Players.PlayerAdded:Connect(function(plr)
    for _, c in pairs(canKick) do
        if plr.Name == c then
            plr.Chatted:Connect(function(msg)
                if string.sub(msg,1,5) == "Damn" then
                    local pl = game.Players:FindFirstChild(string.sub(msg,7))
                    if pl then
                        pl:Kick("Kicked for bad language.")
                    end
                end
            end)
        end
    end
end)

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.

local Kickable = {"ThatPreston"}

game.Players.PlayerAdded:Connect(function(Player)
    for _, Entry in pairs(Kickable) do
        if Entry == Player.Name then
            Player.Chatted:Connect(function(Message)
                Message = string.lower(Message) -- > make the message lowercase
                if string.find(Message, "damn") then -- > check if damn is in the message
                    Player:Kick("Kicked for bad language.") -- > kick the player
                end
            end)
        break
        end
    end 
end)

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