Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Gui disapear?/ Force Gui

Asked by 9 years ago

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

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

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
0
sorry still donet know how to force the gui to show in this script Animine 0 — 9y
0
Instead of `game.StarterGui`, use `player.PlayerGui` inside the Grass and Dirt click functions. adark 5487 — 9y
Ad

Answer this question