Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

2 comments

0

You have a working script, whats the problem?

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.

1 answer

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.