local Players = game:GetService("Players")
local play1Command = "/red"
local function onPlayerChatted(player, message)
if message:sub(1, play1Command:len()):lower() == play1Command then
print("u say red")
end
end
COMMUNITY QUESTION
I wanted to make it that whenever I say red on the chat, it prints red. So how do i fix this code?
1 answer
You forgot to call your onPlayerChatted function
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
onPlayerChatted(plr, msg)
end)
end)
Put this code somewhere in yours, and it should work
Let me know if I helped
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Please next time, before you write a question try to find the answer on the web (the official article for Player.Chatted, for example)