How to fix " Player Argument must be a Player Object"?

How can I fix the error “Player Argument must be a Player Object”?

Here’s the code written in a Script

local changepartcolorevent = game.ReplicatedStorage:WaitForChild("ChangePartColor")
local part = script.Parent
part.Touched:Connect(function(hit)
	changepartcolorevent:FireClient()
end)

This is not a serious code. I’m just practicing Remote Events.

How can I fix this problem?

You need to specify a client in FireClient() - This would be a player object.
For simplicity in your test, I recommend using FireAllClients(), so all clients recieve the event.

2 Likes

Like the LocalPlayer??

chararctesr

1 Like

The syntax is:

RemoteEvent:FireClient(player)

This would be the LocalPlayer, however this cannot be accessed from the server. For testing, you can set player to be game.Players.YOUR USERNAME
It needs to be a player and not a character though.

2 Likes

Thank you!

That was helpful :slightly_smiling_face:

2 Likes

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