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

How do I turn my ScreenGUI on and off?

Hello, I am making a Shop GUI on and I have a exit button (which works) but, I would like to also make a button that toggles the screen GUI on and off

I have had multiple attempts at this but here is what I have so far in my localscript.

local frame = script.Parent.Parent.Parent
script.Parent.MouseButton1Click:connect(function()
	if frame.Enabled then frame.Enabled = true
end)

So all the "Parents" link up to the GUI that I am wanting to toggle, but the rest I just don't understand why it does not work.

Here is the exit button script in case if anyone needs it.

script.Parent.MouseButton1Click:connect(function()
	script.Parent.Parent.Enabled = false
end)

If anyone knows how to help me could they tell me what I did wrong so I could see my mistakes and I am willing to accept their question if it helps me out in any way.

Thank you for reading this!

1 answer

Do you mean Visible in the frame's properties? There is no such property as Enabled in a frame. Let's fix your code!

local frame = script.Parent.Parent.Parent
script.Parent.MouseButton1Click:connect(function()
    frame.Visible = not frame.Visible -- The shortest and easiest way! :D This will toggle the Visible property! Also, the property you are looking for is Visible!
end)

Next time, try look deep into and mess around with a new object's properties to see how they effect the object. That way, you won't be making this mistake again. :)

If you have any questions, please leave a comment down below. Thank you and I hope this will help you!

1 comment

0

Well, there is no property in a SurfaceGUI called "Visible" but there is enabled which basically does the same thing which I used instead of Visible

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