Hello developers, I’m not sure why this isn’t working. Also, I want to clarify that I want the script to be on the client-side and not on the server-side. The script’s parent is StarterPlayerScripts. Please let me know if you find any issues. Thank you.
Script:
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
player.Chatted:Connect(function(msg)
if msg:lower() == "Hello" then
print("CHAT")
else
print("NO CHAT")
end
end)
local player = game:GetService("Players").LocalPlayer
player.Chatted:Connect(function(message)
if string.lower(message) == "hello" then
print("CHAT")
else
print("NO CHAT")
end
end)
local character = player.Character or player.CharacterAdded:Wait()
--???
I tried adding a ‘print’ statement in the first line of the script, which worked correctly and printed ‘hello’. However, I’m still unable to get the chat script to work. Do you have any ideas on what might be causing the issue?
I’m not sure player.Chatted works in a local script.
Try this in a server script:
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
if string.lower(message) == "hello" then
print("CHAT")
else
print("NO CHAT")
end
end)
end)
I thought that the ‘Chatted’ event should work in a local script, and I even saw some videos where it worked. I’m not sure what went wrong with my implementation, but the script you provided seems to work on the server-side. I was hoping to get it working on the client-side, but thank you for your help!
I tried the exact same code, and I found out the problem is likely because TextChatService’s ChatVersion is set to TextChatService. Try switching it to LegacyChatService.
In the lower parts of the explorer, there’s a service called TextChatService. You can select it, and in properties, set the ChatVersion to LegacyChatService.