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

My custom leaderstat GUI shows this error, is it broken? [Answered]

Asked by
1ov3y0u 51
5 years ago
Edited 5 years ago

So, I was making a script for a custom GUI. It says this: Players.1ov3y0u.PlayerGui.Stats GUI.Diamonds.Script:3: attempt to index local 'player' (a nil value) Player is my variable as shown in this code:

while wait() do
local player = game.Players.LocalPlayer
    script.Parent.Text = "Diamonds:"..player:WaitForChild("leaderstats"):FindFirstChild("Diamonds").Value
end

And then I was wondering why it wasn't working, I did everything right. I'm not sure if it's broken or not. I don't know why it's doing that, and this is the only method I know how to make a custom leaderstats.

0
Instead of player, use plr. btw iuclds 720 — 5y

1 answer

Log in to vote
0
Answered by
iuclds 720 Moderation Voter
5 years ago
Edited 5 years ago

It is not in a local script if it shows that error.

game.Players.LocalPlayer

Can only be found using a local script.

Ad

Answer this question