Detection of player chat in the server

Hello developers!
I am trying to detect messages sent by player in the server (not local script) but I am having trouble doing so. I have tried using text chat services but the event does not fire.
(I want to detect player messages through normal scripts and not local scripts)

I can provide the details you want to help me find a solution

Use game.Players.LocalPlayer.Chatted

Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
		--Whatever you want to happen when the player chats here
	end)
end)
1 Like

If my previous response doesn’t help, then yeh please provide details or specifics.

i believe this should work too

I am pretty sure player.Chatted is deprecated and hence I am keeping it as a last resort. Is there any other way?

1 Like

Oh! This is news to me, I didn’t know that. Well ok then the problem isn’t solved, could you tell me what you’re trying to do so I can understand why you don’t want to listen from the client?

1 Like

I am trying to make a pls donate stand and to add products you can use commands. I dont want the model to have any setup and work straight away so I made a local script that detects the commands and put it under a normal script and when the stand is claimed the local script is cloned and put under the player. The issue is that after cloning the local script does not work (i put loops and print statements but nothing works). That’s why I am trying to operate from the server

Try re-enabling the LocalScript once it’s been parented to the player?
Or you can use the RunContext property of a Script and set it to Client

1 Like

Think you can share both of the scripts?

1 Like

I have tried re enabling the local script but it does not work. Could you tell me more about the Run Context?

Don’t have my pc rn I’ll send it once I get on

1 Like

When using LocalScripts, they can only run under certain directories, namely StarterGui, StartPlayer and its descendants, and so on.
When using the RunContext property of the Script instance, it basically allows you to run the code anywhere.
image

2 Likes

Alright once I’m on my pc I’ll try and let you know thanks for now.

Hey I tried it and it works! Thanks alot!

1 Like

Taught me something new, thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.