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

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

Asked by 2 years ago

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
0
This might be silly, but when you instanced the points leaderstat, did you name it "points" Frometa1998 35 — 2y

1 answer

Log in to vote
1
Answered by 2 years ago

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.

Ad

Answer this question