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

Why won't the button in GUI make frame visible?

Hi there, I am making a customizer gui and I want it where if you click the head area (there's a button where the head will be) it opens a new frame, but closes all of the other frames. I used this script before, and it always worked, and it's still working on other things, but for some reason, won't work this one time. There's no errors and the frame isn't visible. Here's the script:

local frame = script.Parent.Parent.HatFrame
local toggle = false
script.Parent.MouseButton1Click:connect(function()
	if toggle == false then
	frame.Visible = true
	script.Parent.Parent.Frame3.Visible = false
	script.Parent.Parent.Frame.Visible = false
	script.Parent.Parent.Frame2.Visible = false
	script.Parent.Parent.TextBox.Visible = false
	script.Parent.Parent.Athletic.Visible = false
		script.Parent.Parent.AthleticDress.Visible = false
			script.Parent.Parent.AthleticJackets.Visible = false
				script.Parent.Parent.Body.Visible = false
					script.Parent.Parent.Dress.Visible = false
					script.Parent.Parent.DressSwim.Visible = false
			script.Parent.Parent.Formal.Visible = false
	script.Parent.Parent.Help.Visible = false
	script.Parent.Parent.Nightgowns.Visible = false
	script.Parent.Parent.Pants.Visible = false
	script.Parent.Parent.Party.Visible = false
	script.Parent.Parent.ShortDress.Visible = false
	script.Parent.Parent.Shorts.Visible = false
	script.Parent.Parent.Skirts.Visible = false
	script.Parent.Parent.Sleepy.Visible = false
	script.Parent.Parent.Swim.Visible = false				
	toggle = true
	else
	frame.Visible = false
	toggle = false

	
	end
end)

Sorry for it being so long, thank you!

2 answers

I wrote 2 separate scripts for you to try. This first script cannot toggle all of the frame's visibility between true or false because you haven't implemented it.

local frame = script.Parent.Parent:WaitForChild('HatFrame')
local toggle = false

script.Parent.MouseButton1Click:connect(function()
	toggle = not toggle
	
    if toggle then
		for i, object in pairs(script.Parent.Parent:GetChildren()) do
			object.Visible = false
		end            
		
		frame.Visible = true
    else
		frame.Visible = false
    end
end)

with this second script, I made it to where you can actually toggle the frames when you click the button.

local frame = script.Parent.Parent:WaitForChild('HatFrame')
local toggle = false

script.Parent.MouseButton1Click:connect(function()
	toggle = not toggle
	
    if toggle then
		for i, object in pairs(script.Parent.Parent:GetChildren()) do
			object.Visible = false
		end            
		
		frame.Visible = true
    else
		for i, object in pairs(script.Parent.Parent:GetChildren()) do
			object.Visible = true
		end   
	
		frame.Visible = false
    end
end)

NOTE: these scripts will ONLY WORK if every object in script.Parent.Parent has the Visible property.

14 comments

0

Let me know if you have any more issues

0

Thank you, I will try this and see if it works!

0

Hi, thank you for responding, but these scripts don't work. I tried the first one, didn't work, tried the second, didn't work. Finally, I tried them together, but it still didn't work. Could it be that some of the frames in the GUI aren't visible?

0

Are you getting an error when testing the code?

0

I dont think gui buttons work if they are not visible

0

It does work, but it doesn't make the frame visible, the "HatFrame."

0

I updated the scripts. Try them to see if it works.

0

post any error messages that you recieve

0

Okay, I tried both again and no errors but the frame doesn't turn visible.

0

The script is suppose to work normally. Maybe one of HatFrame's ancestors has Visible set to false? I don't know what else to do since i don't know how your Gui looks like.

0

Does it matter what kind of script it is? It's a local script so does it have to be normal? Yes, some of the frames in the GUI aren't visible.

0

Oh, and the GUI is in a GUI giver script, if that helps.

0

It's suppose to be in a local script since you are working with GUIs

0

It is a local script.

Thank you AbusedCocopuff4 for trying to help but unfortunately, it didn't work. I have come up with a solution, making it where it just opens a new gui but closes the old one. Once again, thank you!

1 comment

0

np

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