Would this work to call a function by chat?
game.Players.PlayerAdded:connect(function(pName) pName.Chatted.chat() end)
You were so close! Good job!
Your only mistake was line 2.
game.Players.PlayerAdded:connect(function(pName) pName.Chatted:connect(function (msg) -- Code -- Example code: if msg == "hi" then m = Instance.new("Message") m.Text = pName.Name ..' said "hi!" ' wait(3) m:Destroy() end end) end)
This would create a message with the Players name, then, 'said "hi!" '
Chat is an event under a Player, so it needs a connect. Much like the PlayerAdded, which is under players. Then, in your function, whatever you put in the ()'s are the
This code is self explanatory. When a player is added, a Chatted event is attached to the player. The argument "message" is passed from the event.
game.Players.PlayerAdded:connect(function(player) player.Chatted:connect(function(message) end) end)