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

if stage.value = ... then frame.visible = true/false not working pls help! :) (?)

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


if plr.stats.Stage.value == 20 then
	game.StarterGui.ObbySkipStage.Frame.Visible = false
end 

if plr.stats.Stage.value == 0-19 then
	game.StarterGui.ObbySkipStage.Frame.Visible = true 
end

-- tried > and < they don't seem to work for me so i changed to 0-19 because it doesn't say it's wrong (error)...

Basically what i'm trying to do here is to make it so if ur on stage 20 in my obby, which is max u can get to, then u can't see the skip stage button anymore, don't want ppl to get over stage 20 using it + paying for nothing pretty much.

10 comments

0

its not 0-19, its if stats.Stage.Value >= 0 and stats.Stage.Value <= 19 then plr.PlayerGui.StarterGui.ObbySkipStage.Frame.Visible = true end   and I would also recommend that you disable ResetOnSpawn so that if he dies, it doesn't appear again

0

ooh

0

If this worked add [SOLVED] in the title

0

it still doesnt make the frame visible = false tho.. :(

0

I updated my comment

0

ok, ty ill read it.

0

just saying but i want ppl that has 0 in stages to see it :/..

0

pls contact me on disc, alot easier. = Fuze#4779

0

= 0 mean larger than or equal to 0

0

I sent you a request.

1 answer

well, the code is fine but the problematic part if 0-19, while in human language that can specify a range, but in computers that means zero minus nineteen or take 19 away from zero which would result in -19, and therefore not raising any errors because it's a valid expression.

also, btw, bind your code to an event, so whenever the value of their stage changes, then a function runs..

to fix this, you could write your code like this

local plr = game.Players:WaitForChild("LocalPlayer")
local stats = plr:WaitForChild("leaderstats")
	
	
plr.stats.Stage.Changed:Connect(function()
	if plr.stats.Stage.value == 20 then
	    game.StarterGui.ObbySkipStage.Frame.Visible = false
	end 
	
	if plr.stats.Stage.value >0 and  plr.stats.Stage.value < 20 then
	    game.StarterGui.ObbySkipStage.Frame.Visible = true
	else
		--if somehow the stage values aren't between 0 and 20
		--put handling code here
	end
end

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