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

if stats.Stage.Value == 20 then script.Parent.Visible = false not working (?) help pls :)

local plr = game.Players.LocalPlayer
local stats = plr:WaitForChild("leaderstats")

if stats.Stage.Value == 20 then
      script.Parent.Visible = false
      
end 

if stats.Stage.Value >= 0 and plr.stats.Stage.Value <=19 then
      script.Parent.Visible = true 
      
end

-- this is a localscript inside the gui's frame.

Line 1 should make the frame visible = false so invisible for ppl on stage 20, so they dont glitch the system by making them stage 21 when there aren't one.

Line 2 should make it visible for ppl that are on stages 0 to 19.

Line 9 in code error:

17:27:43.079 - Players.popu2004.PlayerGui.ObbySkipStage.Frame.SkipStagePrevent:9: attempt to compare number with string

3 comments

0

change local plr = game.Players:WaitForChild("LocalPlayer") to game.Players.LocalPlayer

0

Yeah. You're trying to find the first child named LocalPlayer in Players when there is none. Game.Players.LocalPlayer is like "predefined" and is not an object sorry im tired i cannot word this any better XD

0

"17:27:43.079 - Players.popu2004.PlayerGui.ObbySkipStage.Frame.SkipStagePrevent:9: attempt to compare number with string" error

1 answer

✓ Accepted answer

heres your fixed code:

at line 9 your first compare was ok but when it comes to 2nd compare a issue should appear

you made 2nd compare like this: plr.stats.Stage.Value which means: plr.plr.leaderstats.stage.value but it should like this: plr.leaderstats.stage.value

local plr = game.Players.LocalPlayer
local stats = plr:WaitForChild("leaderstats")
local value = tonumber(stats.Stage.Value) 

if value == 20 then
      script.Parent.Visible = false
end 

if value >= 0 and value <= 19 then --line 9
      script.Parent.Visible = true 
end

-- this is a localscript inside the gui's frame.

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