Level status doesn't work. Their are no errors. When player gets level 3 or higher it stays saying noob. Does someone know what I did wrong? Thanks.
May if I use elseif
then else
?
wait (2) local user = game.Players.LocalPlayer local stats = user:WaitForChild("leaderstats") unlock = stats:WaitForChild("Level") while true do wait(0.5) if unlock.Value >= 1 then script.Parent.Parent.NameLVL.Text = "Noob" else if unlock.Value <= 3 then script.Parent.Parent.NameLVL.Text = "Noob" else if unlock.Value >= 3 then script.Parent.Parent.NameLVL.Text = "Beginner" else if unlock.Value <= 5 then script.Parent.Parent.NameLVL.Text = "Beginner" end end end end end
Yes you want to use an elseif, this will do the following if the previous condition was false and the current condition is true. Also your code has some logic errors, like if the level is 3 then you have an issue with them being a "noob" or a "beginner". Also don't use a while loop, use an OnChange() function, this will fire whenever the user's level changes, instead of looping forever, inefficiently.
wait (2) local user = game.Players.LocalPlayer local stats = user:WaitForChild("leaderstats") unlock = stats:WaitForChild("Level") unlock.Changed:connect(function(unit) -- When their level changes wait(0.5) if unit.Value > 0 and unit.Value < 3 then -- If the value is inbetween 0 and 3, so 1 or 2 script.Parent.Parent.NameLVL.Text = "Noob" elseif unit.Value > 2 and unit.Value < 6 then -- If the value is inbetween 2 and 6, so 3, 4, or 5 script.Parent.Parent.NameLVL.Text = "Beginner" end end)