I have tried to make a onChatted script however, I keep on failing. Please help me.
COMMUNITY QUESTION
How do you make a onChatted script, like admin commands?
3 answers
Hi XMessi10,
I understand, I also had difficulty understanding how to do onChatted scripts before, so I made a simple onChatted script for you. Here ya are:
game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(msg)
if(msg == "") then
-- do something
end
end)
end)
Hope this helps!
- war8989
Use the player.Chatted event. For example :
game.Players.Player.Chatted:connect(function(Message)
print("game.Players.Player has said : "..Message)
end)
If you're looking for some more example codes, the wiki has a whole article about chat commands : http://wiki.roblox.com/index.php?title=Chat_commands
I noticed that the tag was "LocalScripts", and these scripts must be global if you use .PlayerAdded (Pretty sure)
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
The script example I gave is meant to check if a player says something, so if you would like to test it, add something in between the quotation marks and replace the comment with whatever you want.
Thanks I'll try it out.