Hello. For some reason, plr.Chatted isnt working on the client. It works on the server but I am trying to get it to work on the client. I made a new local script and placed it in StarterPlayerScripts but it doesnt print anything.
As @GIassWindows has mentioned, the .Chatted event does not work in a LocalScript, only in a server script. Assuming you don’t have the legacy chat enabled, there is a simple workaround to the problem at hand. I will share some sample code if it helps, but the way to do it is to get the TextChatService service, then use the .SendingMessage event to tell when the player is sending a message. There, you can grab the chat message, and do whatever you want with it. (NOTE: This only works in a LocalScript, so do you .Chatted in a server script.)
local TextChatService = game:GetService("TextChatService")
TextChatService.SendingMessage:Connect(function(ChatMessage)
print(ChatMessage.Text) -- prints whatever the player said (as ChatMessage is NOT the text of the chat messge)
end)
Basically, Roblox revamped the legacy chat, and made it even better, with the benefit of the same features. Though they couldn’t remove legacy chat; it could break games that still uses it, or the other people who still want to use it. Hopefully that was a clear enough explanation for you, didn’t want to make it too long!
Yes, you are correct. Infact, the description for it says it can only be called on the client: “Fires when TextChannel:SendAsync() is called by the sending client.” (By the way, TextChannel:SendAsync() does NOT have to be sent in a script for it to register, sending a message on the client already fires that (just to clear up any confusion).
Hi, sorry for the late reply. It works perfectly. I am using the TextChatService Custom command which I never knew about before, so thank you for telling me about TextChatService