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

Why wont the GUI disappear?

Asked by 9 years ago

So I have a script made that when the value of the NumberValue is greater than 1, it is supposed to make the visible trait of the frame false. Anyone know how to fix this?

local Slide = script.Parent.Parent.Parent.Number
local Container = script.Parent.Parent
while true do
    if Slide.Value > 1 then
        Container.Visible = false
    end
end

So there is a TextButton that, when clicked, changes the number value to 2 of the NumberValue. Here is the script I used to do that in case that helps. After this script triggers it will trigger my other script (The one that is posted above) that I put inside a TextBox which displays the title of my game.

local Slide = script.Parent.Parent.Parent.Number
function onClick()
    if Slide.Value < 2 then
        Slide.Value = Slide.Value + 1
    end
end
script.Parent.MouseButton1Click:connect(onClick)

The hierarchy of this stuff is the following: StarterGui, ScreenGui, Frame (Renamed Holder), then a NumberValue (Renamed Number) and a Frame (Renamed Container), then inside of Container is a TextButton (Renamed Next) and a TextBox. There is a script inside the TextButton and the TextBox. The script in the TextButton is the second script posted above. The one that is not working is inside the TextBox.

1
I cannot help you without knowing your hierarchy of the GUI. Like if its named ScreenGui,Frame,TextButton or whatever. Please tell me and I'll help. alphawolvess 1784 — 9y
1
While true do without a wait will crash YellowoTide 1992 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

You really shouldn't be using a while true do loop for making a GUI's visible become false. Instead of having a script add a number into a value and then continously check if it's the correct condition to continue your script, you just should have a button you'll press to make it be "Invisible". I don't see anywhere in your script where it will be possible to make it visible again, so I will not be using a NumberValue or any of those because all you're doing is making it "Invisible".

GUI's should use LocalScripts! This script should be in a LocalScript, if it's in a script it will NOT work. This localscript is going to make the GUI invisible: (Put into TextButton)

script.Parent.MouseButton1Click:connect(function() -- This is how I do my functions...
    game.Players.LocalPlayer.PlayerGui.ScreenGui.Holder.Number.Container.Visible = false
end)

Now you no longer need the other script.

Comment questions/problems!

0
Make sure my hierarchy is correct for you! Accept/Upvote if this works. alphawolvess 1784 — 9y
0
It still is not making everything disappear. I will have more GUIs once I click the Next button so I dont want the Holder to disappear. I want the Container to disappear and I will have more frames appear once I click the Next button. Malefactus 55 — 9y
0
So, just adjust i'll adjust it to work for container alphawolvess 1784 — 9y
0
Alright. It worked! The only thing was that Container was not inside of the number. But it works now! Thanks so much. I owe ya. :D Malefactus 55 — 9y
Ad

Answer this question