I am working on the open/close GUI menu and I have a problem.
My GUI won't open!
Here is my GUI Open Button Script;
function onClick() -- starts function programming script.Parent.Parent.Frame.Visible = true -- Makes Frame Visible local frame = script.Parent.Parent.Frame -- shows where frame is script.Parent.Visible = false -- Makes Open Button Invisible script.Parent.Parent.Close.Visible = true -- Makes the close button Visible end -- ends function programming script.Parent.MouseButton1Down:connect(onClick)
and here is my GUI CLose Button Script;
function onClick() -- starts function programming script.Parent.Parent.Frame.Visible = false -- Makes Frame Invisible local frame = script.Parent.Parent.Frame -- shows where frame is script.Parent.Visible = true -- Makes Open Button Visible script.Parent.Parent.Close.Visible = false -- Makes the close button Invisible end -- ends function programming script.Parent.MouseButton1Down:connect(onClick)
How am I supposed to make my GUI open? What did I do wrong?
Tell me if you need any more information to answer this question! :)
You can technically do this in one script as a toggle visibility. The problem you are having with this is that you are simply telling it that when you click you are doing this:
-make script.Parent.Parent.Frame visible while in the other script simultaneously making it not visible -declaring that script.Parent.Parent.Frame can also be called "frame" (Which you don't use at all) - make this.Parent visible while also making it not visible in the other. (which one isn't capitalized) - then making close true.
So main problem you are making a GUI item visible and not visible at the same time.
Okay, I saw your script and I tested it. The way you're doing in it is a bad method.
You can do it in the same script.
script.Parent.MouseButton1Click:connect(function() if script.Parent.Parent.Frame.Visible == false then -- If visible of frame is false, it will be set to true. script.Parent.Parent.Frame.Visible = true script.Parent.Text = "Close Shop" -- Changes the text of the button to Close shop elseif script.Parent.Parent.Frame.Visible == true then --if visible of Frame is true, shop will close. script.Parent.Parent.Frame.Visible = false script.Parent.Text = "Open Shop" --Changes the text of the Button to Open Shop end end) end
Always remember to check if the Frame is visible before doing anything else.
The rest I believe you understand :)