leaderstats is not a valid member of Player "Players.Player1"in Roblox Luau: what it means and how to fix it
What it means
You used a dot to reach a child or property that does not exist on that object at the moment the line runs. The text in quotes is the full path of the object you looked inside.
The smallest script that triggers it
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
player.leaderstats.Coins.Value = 100
end)
The fix
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local leaderstats = player:WaitForChild("leaderstats")
local coins = leaderstats:WaitForChild("Coins")
coins.Value = 100
end)
WaitForChild pauses until the child exists, so the line no longer runs before another script has created leaderstats.
Common causes
- The child is created by another script and does not exist yet when this line runs.
- The name is misspelled or has different capitals. Names are case sensitive.
- The object is in a different place than the path says, for example in ReplicatedStorage and not Workspace.
Practice this until it sticks
A Deep Dive on WaitForChild and FindFirstChild: 5-minute lessons, each with a quiz. What you miss comes back in the next module. One Deep Dive a day is free. No card.