Close GUI Help (Frame To ImageLabel)

Hello everyone, so I am working on this club game (I’m only a builder so I only know very very simple scripting) and I need help with a button that closes my music gui. I’m currently using a script/model from YouTube for the close button but the problem is it requires a frame and the core of my gui is image labels, I’ll leave the ScreenGUI & Close Button Script below, any help will work thanks!

My Screen Gui buttons


Close Button Code

local frame = script.Parent.Parent.Frame
frame.Visible = false
script.Parent.MouseButton1Click:Connect(function()
if frame.Visible == false then
frame.Visible = true
else
frame.Visible = false
end
end)

Well for starters

local frame = script.Parent.Parent.Frame

Will grab StarterGui
So Change that to

local frame = script.Parent.TheNameOfYourImageLabel

And change “else” to

elseif frame.Visible == true then

Other than that you should be good

So for local frame = script.Parent.TheNameOfYourImageLabel Would that close all of my labels if I named all of them the same thing?

No it would not if you wanted all of them to close you have to use a “for” loop combined with “GetChildren” thats’ why the script has them defined in a frame because if you set the frames Visible property to false everything inside it becomes invisible as well

Well, why can’t you just include a frame and have your imagelabels under it?

 Main Frame >
     > imagelabel 1
     > imagelabel 2 
     > close button (closes frame)

Also, just a sidenote, you can simply your else statements by so:

script.Parent.MouseButton1Click:Connect(function()
frame.Visible = not frame.Visible
end)

I had to change “true” and false around so it would close when visible but it worked thank you!