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!

14 comments
Let me know if you have any more issues
Thank you, I will try this and see if it works!
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?
Are you getting an error when testing the code?
I dont think gui buttons work if they are not visible
It does work, but it doesn't make the frame visible, the "HatFrame."
I updated the scripts. Try them to see if it works.
post any error messages that you recieve
Okay, I tried both again and no errors but the frame doesn't turn visible.
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.
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.
Oh, and the GUI is in a GUI giver script, if that helps.
It's suppose to be in a local script since you are working with GUIs
It is a local script.