Well, many games have a type system you open one UI and if you have another open the other closes and I wanted to know a way to do this.
The only way I know is by checking a frame by one to see if it's open ex:
--[[ if frame2.Visible == true or frame3.Visible == true or frame4.Visible == true then frame2.Visible = false frame3.Visible = false frame4.Visible = false frame1.Visible = true end --]]
Method 1:
local LastOpenedFrame Button1.MouseButton1Down:Connect(function() if LastOpenedFrame and LastOpenedFrame ~= AFrame then LastOpenedFrame.Visible = false end AFrame.Visible = true LastOpenedFrame = AFrame end)
Method 2:
Button1.MouseButton1Down:Connect(function() for _, Frame in next, MainFrame:GetChildren() do if Frame ~= AFrame then Frame.Visible = false end end AFrame.Visible = true end)