I cant hide chat messages if it has specific text

I need help. Does anyone know how to hide messages in chat if it has a specific text character in the first text character of the message? Because I saw an article on how to do it but I cant access chat modules for some reason.

Somewhat confused, by character do you mean “ABCD” or the player?

1 Like

Oh sorry I meant like ABCD. Like a text not player’s character

Alright start off with this:

-- SERVER SCRIPT (IN SERVERSCRIPTSERVICE)
local function onPlayerJoin(player) 
	player.Chatted:Connect(function(msg)
		local Table = string.split(msg:gsub("%p", " "), " ")

		for _,msg in pairs(Table) do
            -- Use msg, remove all characters they typed unless it's the first one, and check if the first one is a specific letter.
		end
	end)
end

game.Players.PlayerAdded:Connect(onPlayerJoin)

I don’t really want to give you the full code, so encourage yourself to learn how to use strings, there’s a lot of tutorials, if you do want farther help on this, just let me know.

2 Likes

Thank you, but how can I make the message hidden now? I already did a detector if the message has a certain text at the start.

-- SERVER SCRIPT (IN SERVERSCRIPTSERVICE)
local function onPlayerJoin(player)
	player.Chatted:Connect(function(msg)
		-- Remove all non-alphanumeric characters except for the first character and semicolons
		local filteredMsg = msg:gsub("[^%w;]", "", 2)
		print(filteredMsg)

		-- Check if the first character of the filtered message is a semicolon
		if filteredMsg:sub(1, 1) == ";" then
			print("Message hidden")
			return "" -- I want this line to turn message to hidden, but it doesnt
		end
	end)
end

game.Players.PlayerAdded:Connect(onPlayerJoin)

Yeah so, I don’t know why your returning, as that does nothing at all.

But, to achieve this, I recommend checking this - link out!

1 Like