Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

.Chatted not working as intended?

I have a script that uses player chatted to set a players class, here's a base of what I want the script to look like:

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		if msg == "here" then
			print("lol")
		elseif msg == "here2" then
			print("lol1")
		end
	end)
end)

If I say here it works, but if I say here2 it doesn't, how would I get around this (without changing the message)

1 answer

I recommend using Players.PlayerChatted to do this.

local example = “test”
if msg:sub(1, example:len()) == example then
    print(“message starts with “ .. example)
end

3 comments

0

Apologies for the wrong unicode quotes, I’m currently on mobile.

0

Thank you!

0

If I solved your problem, please mark this as the solution :)

This discussion is preserved as it was. New answers, comments, and votes are closed.