Open one GUI, Close the previous one

What do you want to achieve and What is the issue?
(Check Image) Imagine that those Yellow Dots are buttons and each one opens a GUI… What could I do so that when I open one gui, the previous gui that was opened closes and the new one opens? Need help with this, please…

What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried asking in some Roblox Discord servers that have people who helps with scripts and that stuff but i wasn’t lucky…

Image

Was using this simple code but it doesn’t work for what i want to achieve…

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

Thanks in advance for helping me out!

script.Parent.MousButton1Click:Connect(function()
   for i, v in ipairs([GUI]:GetChildren) do
     if v.Enabled then not v.Enabled
     end
   end
   script.Parent.Enabled = true
end)

Could you explain me how this code works, please? Thanks.

wait I messed up on something, but I could explain it, when the yellow button is clicked I use a for loop which goes through everything inside the Gui that you want (change it if you didn’t know that) and then I check if v(the item) is enabled and if it is, I disable it change it to v.enabled = false and then after the for loop is finished I set the GUI that you want to enabled since we don’t want it to be disabled again in the for loop I 'll send sen an actaully working version with comments if you didn’t get that

just show the one gui you want to show and disable the others you dont want to show. might take a while but it’s probably the easiest way

script.Parent.MousButton1Click:Connect(function()
--code here   
break
end)
script.Parent.MousButton1Click:Connect(function()
   for i, v in ipairs([GUI]:GetChildren) do -- loop through everything inisde the parent of the gui that you might want to close
     if v.Enabled then -- check if it's enabled
       v.Enabled = false -- if it is disable it
     end
   end
   [gui that you want to open].enabled = true -- open it after the for loop so it doesn't get disabled by it
end)

what’s that supposed to do that’s just like what she did

I’m not sure about how to use that code, do i have to keep those []? Also which GUI are u refering to in there? x-x

don’t keep the [] and the last one I mean the one you want to open the top one is the parent of all the guis that you might want to close