Detecting Chats From a Player Not Working

I am making a system that requires detecting chats, but every time I try to use one of the many ways, it doesn’t work.

I attempted to use player.Chatted, etc, but that didn’t work, I also attempted to use the code listed below.

game:GetService("ReplicatedStorage").DefaultChatSystemChatEvents.OnMessageDoneFiltering.OnClientEvent:Connect(function(messageArray)
    local message = messageArray.Message
    print(message)
end)

I believe it may be because of the new chat system, but even when I disabled it, it won’t go away.

Any help will be greatly appreciated.

When you use Player.Chatted it should work perfectly fine for TextChatService and LegacyChatService.

Server-script:

game.Players.PlayerAdded:Connect(function(Player)
    Player.Chatted:Connect(function(Message, Recipient)
        print(Message)
    end)
end)

I attempted to use that, but it still didn’t work, no errors, no response whatsoever.

local script:
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
print(message)
end)
end)

That doesn’t work, attempted to put it in a local & server script but to no avail. I wonder if it has anything to due with it being inside a GUI, but I doubt that would be why.

Can you upload the place file?

Yes I can, I will do that right now

Just to point out; whenever you use Player.Chatted you must use it in a server-script for it to work.

I already displayed that. He said it didn’t work.

radio.rbxl (66.2 KB)

found the solution! its a server script, in workspace it works but not in startergui, the code would be
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
print(message)
end)
end)

I just did some investigating, and it appears to work in scripts stored in ServerScriptService, but not when printed out from a script stored inside a GUI.

I would prefer not to have to move all my scripts outside that GUI, but if I have to I will.

1 Like

remember to mark it as solved so people dont go back in this chat!

If you set Script.RunContext to Server the script will be able to run nearly anywhere, including from GUIs. However, it is much better to keep scripts in ServerScriptService than inside of a gui, unless that script is specifically modifying that gui.

If that works for you then you should put it into ServerScriptService.