Attempt to index number with 'Value'

So I have a simple script that checks if the players lvl value is 3. if it isn’t then it prints no. The thing is that if the player doesn’t have a lvl value of 3, then it produces this error:

Players.ForeverBloxian.PlayerGui.MainGui.SelectStructures.Structures.Lvl3.LocalScript:6: attempt to index number with 'Value'  -  Client -

The script:

local player = game.Players.LocalPlayer

local lvl = player:WaitForChild('leaderstats'):WaitForChild('Level').Value

task.wait(1)
if lvl.Value == 3 then
	print('yes')
	script.Parent.Locked:Destroy()
	script.Parent.Jeeps.Visible=true
	script.Parent.Noob.Visible = true
	script.Parent.Truck.Visible=true
	script.Parent.Van.Visible = true
elseif lvl.Value <= 3 then
	print('no')
end

I hope somebody can help me with this.

You are indexing Value twice, change it to local lvl = player:WaitForChild('leaderstats'):WaitForChild('Level')

2 Likes

No way how did I not see this lol.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.