I need help, with my code

I want to, edit my code, that kicks player after, saying a bad word. But I want to, system kick player, without the developer needing to duplicate, the script and write In another match of bypasses of curse words, like I have to capitalize curse word, for e.g: If I write In the script, curse and then player joins the game and says curse, he/she will be kicked, but they can bypass It, by capitalizing one letter, Also If I say It like this: Curse Curse or curse, It doesn’t do anything (before the developer, adds the duplicated word, In a script, like a sentence So I need help with It.



Game file, to test.

Test.rbxl (17.0 KB)

Script
local msg = "curse word"

game.Players.PlayerAdded:Connect(function(player)

player.Chatted:Connect(function(m)

if m == msg then

player:Kick()

end

end)

end)

use string.lower while comparing (msg should be all lowercase too, unless you want to string lower both of them)

if string.lower(m) == string.lower(msg) then

(upon reading your thread again, instead of comparing two of them, you should use string.match + an array containing blacklisted words)

1 Like

There is no need to do this, as there is already a chat filter in place. If you are planning on making a custom chat filter ROBLOX does not like that.

You can bypass, chat filter also, this can help me in another things…

If you want to have your own set of blacklisted phrases on top of the Roblox filter, you could do something like this:

local bannedWords = { -- should be all lowercase
	"curse1",
	"curse2",
	"curse3"
}

game:GetService("Players").PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
		msg = msg:lower()
		for _, phrase in ipairs(bannedWords) do
			if (msg:find(phrase) ~= nil) then
				player:Kick("You said a bad word.")
			end
		end
	end)
end)

Developers are not allowed to disable or bypass the chat filter.

2 Likes

But I also have, one question that I asked, In my topic. What If they bypass, curse words by capitalizing It, like I don’t want a player to say, hello for example, what If they say like HElLo? I will have to, write down all possible matches then, and It takes a time.

With this code it automatically makes it so that the server will see HElLo as hello with string.lower

2 Likes