Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I get one Frame to close after another open?

Asked by 4 years ago

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
--]]
0
You have a working script, whats the problem? Benbebop 1049 — 4y
0
The way I would do this is making a ModuleScript that disables all of the interfaces, then enable the interface you want open with the original script. Benbebop 1049 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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)
Ad

Answer this question