So I get this error saying

10:20:57.641 - Workspace.Unlock:3: attempt to index local 'leaderstats' (a nil value)

I am not sure why this happens I tried using everything I could, but I couldn't figure it out here is the script

local plr = script.Parent.Parent
local leaderstats = plr:FindFirstChild("leaderstats")
local Points = leaderstats:FindFirstChild("Points")
local Part = game.Workspace.Part


if Points.Value < 1 then
	Part.Transparency = 1
end

If you can help me thanks

2 comments

0

I'd try changing the "FindFirstChild" at line 2 to a "WaitForChild"

0

I agree with Lamantinel, as this code may run faster than when the game creates the leaderstats for the player.