Chatted function

Hey! I’m trying to upgrade a singleplayer horror experience I made to be supported in a multiplayer version.

I had an event that detects if a player sends a message in chat:

player.Chatted:Connect(function(msg)
	
	
	workspace.Anthony:Play()
	
	
end)

This function still works but only for one player in-game.

The script is located inside of a GUI:
image

The game functions the same across all clients so far and I’ve managed to optimize it but I’m stuck on this step. What’s the best way to detect if ANY user in the game sends a message and for a response (in this case the audio playing) to replicate for all players and for the script to continue after the event.

Thank you!

1 Like

It only will work for one person since its a localscript on the client.

On player join, set a Chatted listener to them on the server.

The reason that only one client can hear the audio is because this is in a local script. You should use a remote event that fires an event to all clients (or the server) that plays the audio.

Yeah, I get that. but what would be the best alternative to this? I understand a server script but like, what’s the best way to replicate this to all clients whilst also allowing the rest of what’s inside the local script to continue after.

game.Players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)
        workspace.Anthony:Play()
    end)
end)
2 Likes

Hey, i need a script so when someone in game says a specific word, e.g hello, something happens with the chatted event