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

What is a player object?

Asked by 3 years ago

There was an error when I wanted to pass getchildren in fireclient, and it said "FireClient: Player argument must be a player object". I changed the data to just Score which was in player (which I already declared via other remote events) because I thought since it was a descendant from player it would be considered a player object. WRONG. What do I do?

0
A player object is the player themselves. lemony_dev 9 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

The way you can solve this is in the following code:

--Script

local remoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")

game.Players.PlayerAdded:Connect(function(player) --this parameter is the player object
    remoteEvent:FireClient(player)
end)

-- ==========================================
--LocalScript
local remoteEvent = game.ReplicatedStorage.RemoteEvent
local player = game.Players.LocalPlayer

remoteEvent.OnClientEvent:Connect(function()
    --YourCode
end)

If this works for you, make this the solution.

Ad

Answer this question