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.
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.