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

How to make a open and close gui?????

So here is my code I used: script.Parent.MouseButton1Click:connect(function()

script.Parent.Parent.Frame.Visible = not script.Parent.Parent.Frame.Visible

end)

StarterGUI>ScreenGUI>Frame and I put the open and close gui in that screenGUI too. I put that code in the local script of the frame that I named OpenAndClose.

3 answers

2 Things.

  1. Frames don't have a MouseButton1Click function.
  2. Your script could be in the wrong location OR the ammount of .Parents is too high/low. (Acording to you saying that it's in the frame, it should be good, so it's probably point 1. that is messing up your script.)

If i run your code (without click function) it works fine. Have you checked the "Output" window for any errors? (>Top >View >Output)

Shown that your code would work: https://gyazo.com/9c93099996d25a909b5d733dfa70eab1

Ok first of all, Frames don't have MouseButton functions. Second of all, your code would run fine if it had a Text Button instead of the frame. Set the Text Button to have no text. If you really want a frame, just put the Text Button ontop of it with a higher Z-Index

I'm not your spoonfeeder.

All you have to do is to have your gui, and then a TextButton. Use MouseButton1Click or any mouse events that makes sense in your situation, and the best way would be to check if the gui is open, do a simple if statement on the gui property «Visible»

No need for elseif when dealing with boolean stuff

--Assuming you set Shop to your frame 
if Shop.Visible == true then
--Open

else

--close
end

I'm writing from my phone, I'm sorry if I made any mistakes...

1 comment

0

Theres not even need for an if statement if its just switching a boolean. Value = not Value does the same.

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