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

FireClient: player argument must be a Player object?

Error : FireClient: player argument must be a Player object

Script :

script.Parent.Touched:Connect(function()
     script.Parent.RemoteEvent:FireClient()
end)

Local script :


local Player = game.Players.LocalPlayer

script.Parent.RemoteEvent.OnClientEvent:Connect(function()
		local Menu = Player.PlayerGui:WaitForChild("Menu")
		Menu.Frame.Visilbe = true
        Menu.Close.Visible = true
end)

1 answer

✓ Accepted answer

You need to put a player in between the brackets of FireClient(). To get the player, you would have to get the character that touched the part, then take the name of that character and navigate through game.Players. Here's an example.

--  Server Script

script.Parent.Touched:Connect(function(hit) -- hit is the part that touched script.Parent 
	if hit.Parent:FindFirstChild("Humanoid") then -- Checking for a humanoid
		local plr  = game.Players:FindFirstChild(hit.Parent.Name)

		if plr then -- Checking if the player exists
			script.Parent.RemoteEvent:FireClient(plr)
		end
	end
end)

Hope it helps!

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