Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

player Argument must be a Player Object error using FireClient?

I'm using a FireClient remote event to make a GUI pop up for the player being clicked on by another player.

Server Script:

script.Parent.MouseClick:Connect(function(player)
	local playerClickedOn = script.Parent.Parent.Parent
	local guiEvent = game:GetService("ReplicatedStorage"):WaitForChild("GUI").guievent
		guiEvent:FireClient(player,playerClickedOn)
end)

Then, after the player is clicked on by another player, a GUI should pop up for the player who was clicked on.

Local Script:

local guiEvent = game:GetService("ReplicatedStorage"):WaitForChild("GUI").guievent
	guiEvent.OnClientEvent:Connect(function(player,playerClickedOn)
		Player.PlayerGui.YesNo.Enabled = true
		Player.PlayerGui.YesNo.PickUp.Visible = true
		Player.PlayerGui.YesNo.PickUp.TextLabel.Text = player.Name.." has clicked on you"
	end)

However, I get this error:

FireClient: player argument must be a Player object, Line 4

What does this mean and how do I fix this? What I want is for the event where the player that was clicked on has a GUI pop up telling them who clicked on them.

1 answer

✓ Accepted answer

You are sending the event to the wrong player. Assuming the playerClickedOn is a Player Model, add this:

local playerToSend = game.Players:GetPlayerFromCharacter(playerClickedOn)
guiEvent:FireClient(playerToSend, player)

And on the LocalScript, edit this (Not the whole script):

local playerLocal = game.Players.LocalPlayer --Add this below local guiEvent =...
guiEvent.OnClientEvent:Connect(function(theClicker)
--The gui script
end)

Hope this helps :)

3 comments

0

Thank you! The function fires now, but I'm getting a new error. "Attempt to index local "theClicker" (a nil value)

0

I fixed it, thank you!

0

No problem!

This discussion is preserved as it was. New answers, comments, and votes are closed.