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

Gui disapear?/ Force Gui

How do i do so, when it hits 0, the gui will auto disapear.

Gui = script.Parent

WG = game.StarterGui.Health.load

X = Gui.Size

HP = 500

while HP > 0 do
	
	wait()
	HP = HP -10
	Gui.Size = UDim2.new(0,math.floor(HP),0,25)
	print(HP)
	
end

how to do so when i press the "Dirt" the gui will pop up

local Box = script.Parent --Fortæller hvad vi leder efter
local Grass = Box.grass
local jord = Box.dirt


Box.grass.ClickDetector.MouseClick:connect(function(player)
	game.StarterGui.HealthGrass.Screen.Visible = true
	jord.Decal1.Texture = "http://www.roblox.com/asset/?id=48336811"
	jord.Decal2.Texture = "http://www.roblox.com/asset/?id=48336811"
	jord.Decal3.Texture = "http://www.roblox.com/asset/?id=48336811"
	jord.Decal4.Texture = "http://www.roblox.com/asset/?id=48336811"
	wait(2)
	Box:Destroy()
	Grass:Destroy()
end)

--Helping notes

Box.dirt.ClickDetector.MouseClick:connect(function(player)
	game.StarterGui.HealthGrass.Screen.Visible = true
	jord.Decal1.Texture = "http://www.roblox.com/asset/?id=48336811"  --This Changes the DECAL FROM HERE
	jord.Decal2.Texture = "http://www.roblox.com/asset/?id=48336811"
	jord.Decal3.Texture = "http://www.roblox.com/asset/?id=48336811"
	jord.Decal4.Texture = "http://www.roblox.com/asset/?id=48336811"  -- Stops changeing the DECAL HERE
	wait(2) -- Time before the block disapear
	Box:Destroy() -- Destroys the block(Dirt)
	Grass:Destroy() -- Destroy the block(Grass)
end)

1 answer

In your first code block, the while loop will run until HP is equal to zero, so you can assume that any code placed after that loop will only run when HP == 0 is true.

To actually change whether a GUI element is Visible or not, you actually have to set the Visible property, not just access it as in line 3 of the second code block:

Gui.Visible = false --makes it Invisible

Gui.Visible = true --makes it Visible

2 comments

0

sorry still donet know how to force the gui to show in this script

0

Instead of game.StarterGui, use player.PlayerGui inside the Grass and Dirt click functions.

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