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?

Hello,

So, I keep getting errors, not sure how to fix it. "FireClient: player argument must be a Player object"

local repStorage = game:GetService("ReplicatedStorage")

local plankRemote = repStorage:WaitForChild("plankRemote")

local planksTrigger = game.Workspace.FallingPlanks.PlankTrigger

  

planksTrigger.Touched:Connect(function(hit)

local player = hit.Parent:FindFirstChild("Humanoid")

if player then

print("touched")

plankRemote:FireClient(player)

end

end)

Help is very much appreciated!

1 answer

✓ Accepted answer

The problem is that you're referencing the character as the player value. the FireClient function requires that you have the player object as the input, not the character.

local repStorage = game:GetService("ReplicatedStorage")
local plankRemote = repStorage:WaitForChild("plankRemote")
local planksTrigger = game.Workspace.FallingPlanks.PlankTrigger

planksTrigger.Touched:Connect(function(hit)
    local player = hit.Parent:FindFirstChild("Humanoid")
    if player then
	   print("touched")
	   plankRemote:FireClient(game.Players:GetPlayerFromCharacter(player))
    end
end)

2 comments

0

Thank you, although I'm now getting this error: " Player is not a valid member of DataModel"; any ideas?

0

Oops it was supposed to be game.Players not game.Player.

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