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

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

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.

2 comments

0

you have this in a local script yes ?

0

Hi, it was not in a local script but I just tried moving it into one and encountered the same results.

1 answer

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)

7 comments

0

Hi, I appreciate the answer, but I need the parent to be visible as it is the button that gets clicked.

0

Hey, I updated the reply, try this one.

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

0

No problem! Would you mind accepting this as the answer? Goodluck man!

0

Yeah where do I do that at?

0

By clicking "Accept Answer" under the answer

0

Not seeing it. Is there a time/reputation limit?

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