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

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

Asked by 7 years ago

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

Log in to vote
1
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

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

Ad
Log in to vote
0
Answered by
H4X0MSYT 536 Moderation Voter
7 years ago

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

Log in to vote
-1
Answered by 7 years ago

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...

0
Theres not even need for an if statement if its just switching a boolean. `Value = not Value` does the same. RubenKan 3615 — 7y

Answer this question