Chatted Event message not compared to string correctly

Hello,

I was tutoring today and the student wanted to go over admin command stuff. Which I thought would be pretty easy, I’ve developed a few admin commands back in the day. However when running the code the message being given by the Chatted event did not match up with the string being compared. Even when just copied and pasted directly into the chat. Anybody know why?

game.Players.PlayerAdded:Connect(function(player)
	if CheckForAdmin(player) then
		player.Chatted:Connect(function(message)
			if message == "/guard me" then
				print(message)
				game.Workspace.Dummy:Destroy()
			end
		end
	end)
end)

Notes: It is able to get past the ‘CheckForAdmin’ stage, it runs the Chatted event code, but it does not get past ‘if message == “/guard me” then’ and I can’t figure out why.
I know it’s case sensitive but it’s all lowercase. Even copying the string above and pasting it into chat doesn’t work.

1 Like

Your topic is similiar to this topic, and you will find your answer here: Why does Player.Chatted event pass the chat message with "\r" appended to it?/ - #3 by Quwanterz