Tutorial: Player.Chatted Event in new Roblox Chat

Hello, dear developers!

Recently, I came across a rather unusual situation: I had to use some sort of workaround to make the “Player.Chatted” event work in a LocalScript in the new Roblox chat.

The solution is quite simple, actually, but somewhat unusual. I searched here for similar answers and couldn’t find any, so here I go:

  • Create a RemoteEvent in ReplicatedStorage and rename it to “ChattedEvent”
  • Create a ServerScript in ServerScriptService:
game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		game.ReplicatedStorage.ChattedEvent:FireClient(plr, msg)
	end)
end)

In your LocalScript, I suggest using:

local yourFunctionConnection
yourFunctionConnection = game.ReplicatedStorage.ChattedEvent.OnClientEvent:Connect(function(msg)
	print(msg)
end)

In the same LocalScript, when you no longer need to use the function, use:

if yourFunctionConnection then
	yourFunctionConnection:Disconnect()
end

And done! Now you can use Player.Chatted event in the local instance in the new Roblox chat service without having to wait for Roblox team to fix it.

This function is equivalent to using Player.Chatted, and you can also opt for a function that doesn’t need to be disconnected:

game.ReplicatedStorage.ChattedEvent.OnClientEvent:Connect(function(msg)
	print(msg)
end)

It’s even easier!

1 Like