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

Did I do anything wrong with this Open button?

Asked by 8 years ago

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! :)

0
':Connect' is lowercase, so ':connect' TheDeadlyPanther 2460 — 8y
0
Whats the hierarchy look like? Like, whats parented to what? AwsomeSpongebob 350 — 8y
0
Also, visible needs to be capitalized, so 'Visible'. Not 'visible'. :) AwsomeSpongebob 350 — 8y
0
Thank y'all! crazycampercool9 10 — 8y
0
Ok... I fixed all of those things and edited my question, my GUI still won't work! D: crazycampercool9 10 — 8y

2 answers

Log in to vote
0
Answered by 8 years ago

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.

Ad
Log in to vote
0
Answered by 8 years ago

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 :)

0
Would the same programming go into both buttons (opan and close buttons) ? One is making the GUI invisible and one is making the GUI visible, correct? crazycampercool9 10 — 8y
0
Ok... I finally made it visible, but now it won't close! Oh my goodness... crazycampercool9 10 — 8y
0
Just to be clear, this is what is happening; I test the game and there is a purple GUI in front of me. I see two buttons, open and close (And TextBox on the top left corner). I click close: nothing happens. I click open: nothing happens. Also... can I change the Shop part in the coding to just Close / Open... or maybe leave it out in some places? crazycampercool9 10 — 8y

Answer this question