Open / Close System for Two Frames

I have an open/close script that works for one frame. How can I alter the script so that the open/close function works for two frames simultaneously? (both frames are children of my screengui)

My script below is the one I am using right now, which only opens the one frame.

local frame = script.Parent.Parent.Pages -- Replace "TESTFRAME" with your frame name.
local textbutton = script.Parent.Parent["Dances Button"] -- Replace "OPENCLOSETESTFRAME" with your TextButton name.
local open = script.Open
local close  = script.Close
open.Value = true

textbutton.MouseButton1Click:Connect(function()
	if open.Value == true then
		frame.Visible = true
		open.Value = false
		close.Value = true
		textbutton.Text = "Close Dances" -- Change to what you want to say.
	elseif close.Value == true then
		frame.Visible = false
		open.Value = true
		close.Value = false
		textbutton.Text = "Dances" -- Change to what you want to say.
	end
end)
1 Like

make this an else

why not use only one Boolean?

not sure. I know it isnt the most efficient script, but I would just like to figure out how to add another frame.

I have an inquiry, does it open/close one at a time or both at the same time

if open.Value == true then
    textbutton.Text = "Close Dances"
else
    textbutton.Text = "Dances"
end

frame.Visible = not frame.Visible
open.Value = not open.Visible
close.Value = not close.Visible

try this and tell me if it works

same time. I don’t want it all on one frame though because I have moving properties, and don’t want some buttons to move.

this is my new current issue:::

this is my new issue, ill flag this post as it is no longer relevant.