Player.Chatted Does Not Fire

I’ve been trying to split a message which was sent by the script’s local player into args, but the function Chatted doesn’t even fire.

My script:

local Players = game:GetService("Players")

local Player = Players.LocalPlayer


function Chatted(Msg)
	
	local Args = string.split(Msg," ")
	
	print(Args)
end

Player.Chatted:Connect(Chatted)

NOTE: I tried adding print() before defining the function, it worked (which means the script is active). But somehow, the function still does not fire.

1 Like

Are you using a Local script? For chatted events to work properly, you need to use server scripts. Not on the client.

Heres an example of the code.

local Players = game:GetService("Players")

function Chatted(Message)
	local Args = string.split(Message, " ")
	
	print(Args)
end

Players.PlayerAdded:Connect(function(Player)
	Player.Chatted:Connect(Chatted)
end)

NOTE: make sure the server script is parented to ServerScriptService.

2 Likes

Ah yes, I noticed that it works on server scripts only litlte ago aswell, thank you for your reply.

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