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

Why wont the GUI disappear?

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.

2 comments

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.

1

While true do without a wait will crash

1 answer

✓ Accepted answer

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!

4 comments

0

Make sure my hierarchy is correct for you! Accept/Upvote if this works.

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.

0

So, just adjust i'll adjust it to work for container

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

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