So I have this code that is supposed to delete the message a player makes if it contains "hello", and then kick the player. But whenever I try to run it it doesn't get destroyed, here's the code:

local bad = "hello"

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg, recipient)
		msg = msg:lower()
		if msg.find(bad) then
			msg:Destroy()
			plr:Kick()
		end
	end)
end)

I have no idea why this is happening, any help is appreciated!

6 comments

0

can you try to print the msg? also is it a script or localscript? where is it located?

0

@CaioAlpaca i changed the name, i forgot to and its a serverscript in workspace

0

you can't destroy a string

0

idk what you are trying to do

0

The how would I go about destroying the message, not the string?

0

The how would I go about destroying the message, not the string?