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!
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!