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

I'm trying to make a GUI backpack and clicking it won't open it?

Asked by 5 years ago

I've spent the past 3 hours trying to figure this seemingly simple thing out and I'm about to rip my hair out. So all I want is to be able to click on this TextButton, and have it make the other TextButtons visible upon clicking if they're currently not visible, or make them invisible if they're currently visible. Here's my code:

Button = script.Parent
Button1 = Button.TextButton1
Button2 = Button.TextButton2
Button3 = Button.TextButton3
Button4 = Button.TextButton4

function clicked()
    if Button.Value == false then
        Button1.Visible = true
        Button2.Visible = true
        Button3.Visible = true
        Button4.Visible = true
        Button.Value = true
    elseif Button.Value == true then
        Button1.Visible = false
        Button2.Visible = false
        Button3.Visible = false
        Button4.Visible = false
        Button.Value = false
    end
end

script.Parent.MouseButton1Click:connect(clicked)

Value is just a Boolean value I have that is a child of the text button that is supposed to be clicked so I don't have to type up code that checks if each individual button is visible or not. The script's Parent is the button that is getting clicked. The other button's are children of this button, and start off not visible. I know there are simpler ways to write this but none of the way I tried work and this was just my latest attempt at a work around that didn't work. Nothing is going wrong in the script according to output. I've only tested it in studio using the "Play Here" button, not in an actual server. Help me please.

0
you have this in a local script yes ? Hizar7 102 — 5y
0
Hi, it was not in a local script but I just tried moving it into one and encountered the same results. pepsirune101112 0 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Hey pepsirune101112,

If you set the parent of all the textButtons to Visible = false all of the children become invisible as well

Button = script.Parent
Button1 = Button.TextButton1
Button2 = Button.TextButton2
Button3 = Button.TextButton3
Button4 = Button.TextButton4

function clicked()
    if Button1.Visible == false then -- if it is invisible make it visible
        Button1.Visible = true
        Button2.Visible = true
        Button3.Visible = true
        Button4.Visible = true
    else -- if it is already visible then make it invisible
        Button1.Visible = false
        Button2.Visible = false
        Button3.Visible = false
        Button4.Visible = false
    end
end

script.Parent.MouseButton1Click:connect(clicked)
0
Hi, I appreciate the answer, but I need the parent to be visible as it is the button that gets clicked. pepsirune101112 0 — 5y
0
Hey, I updated the reply, try this one. PoePoeCannon 519 — 5y
0
Awesome! It worked, thanks a ton. Really simple once I see it working. Once again thank you so much you're my hero <3 pepsirune101112 0 — 5y
0
No problem! Would you mind accepting this as the answer? Goodluck man! PoePoeCannon 519 — 5y
View all comments (3 more)
0
Yeah where do I do that at? pepsirune101112 0 — 5y
0
By clicking "Accept Answer" under the answer User#19524 175 — 5y
0
Not seeing it. Is there a time/reputation limit? pepsirune101112 0 — 5y
Ad

Answer this question