Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why do i get this error,and how can i fix it? i want to show an amout of points on a label

i want to show an amout of points on a label, and for some reason i get this error

Players.Medoozi.PlayerGui.InsertedObjects.Gradient.TextLabel.LocalScript:8: attempt to index nil with 'points i've checked and i havent misstyped anything...

local Players = game:GetService("Players")
local number = script.Parent
local player = game.Players.LocalPlayer
local leaderstats = Players:FindFirstChild("leaderstats")

while true do
	wait()
	number.Text = "Cash:"..leaderstats.points.Value.."$"
end

1 comment

0

This might be silly, but when you instanced the points leaderstat, did you name it "points"

1 answer

✓ Accepted answer

On Line 4, you are trying to find the child named "leaderstats" inside the Players service. This will most definitely return nil because the instance you're trying to find is not a child of Players. Instead of "Players:FindFirstChild("leaderstats")", you should do "player:FindFirstChild("leaderstats")".

Hope this works! if it works, mark it as an answer because it helps out everyone. If it didn't work, leave a comment and I'll try to find another solution.

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