One Script to Open/Close every Gui help!

What I’m trying to figure out:

So I want to figure out how to write a open/close in one main script. So I only have one on screen at a time if you get what I mean. So if I had a shop UI open and tried opening an Inventory UI it will close the Current UI. If you have a concept of how one can achieve this it will be great.

3 Likes

If you have the frames all inside one Gui that you want to close it will make it a lot easier. But it’s still pretty easy to close the others

Example:

script.Parent.MouseButton1Down:Connect(function()
frame1.Visible = true
frame2.Visible = false
frame3.Visible = false
end)

I hope this helps, even though you probably wanted something to be a lot easier, but in my head this is the easiest solution I have.

What i meant by having it all in one Gui is below

4 Likes

Let’s say you have a folder of all of the frames that you do not want to overlap:

for _,frame in pairs(folder:GetChildren()) do
   frame.Visible = false
end
TargetFrame.Visible = true

Whereas TargetFrame is a reference to the UI that is actually going to be opened, i.e the Shop/Inventory depending on which button is pressed.

The loop in this scenario allows for the iteration through each frame and setting them all to false as you can infer, then all it takes is setting the target frame’s visible value to true in order to accomplish the intended function.

5 Likes

Example:

script.Parent.MouseButton1Down:Connect(function()
ExampleFrame.Visible = not ExampleFrame.Visible
end)

Hope this will help.

4 Likes