Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

FireClient: player argument must be a Player object?

Asked by 5 years ago

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

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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)
0
Thank you, although I'm now getting this error: " Player is not a valid member of DataModel"; any ideas? Similaritea 58 — 5y
0
Oops it was supposed to be game.Players not game.Player. Vinceberget 1420 — 5y
Ad

Answer this question