Help! I need help closing frames

My Code:

local MainFrame = script.Parent.Parent.Parent.MainFrame
local drop = script.Parent
local menu = drop.Menu
local open = menu.Open.Value
local selection = drop.Selection
local Frame1 = script.Parent.Parent.ButtonsDropdown
local Frame2 = script.Parent.Parent.FramesDropdown
local Frame3 = script.Parent.Parent.LightingDropdown
local Frame4 = script.Parent.Parent.IconsDropdown
local Open1 = Frame1.Menu.Open
local Open2 = Frame2.Menu.Open
local Open3 = Frame3.Menu.Open
local Open4 = Frame4.Menu.Open

local function closeFrames()
	for _, item in ipairs(Frame2:GetChildren()) do
		if item:IsA("Frame") then
			item:TweenSize(UDim2.new(1, 0, 0, 0), "Out", "Sine", 0.15, true)
			wait(0.01)
			item.Visible = false
		end
	end
	for _, item in ipairs(Frame3:GetChildren()) do
		if item:IsA("Frame") then
			item:TweenSize(UDim2.new(1, 0, 0, 0), "Out", "Sine", 0.15, true)
			wait(0.01)
			item.Visible = false
		end
	end
	for _, item in ipairs(Frame4:GetChildren()) do
		if item:IsA("Frame") then
			item:TweenSize(UDim2.new(1, 0, 0, 0), "Out", "Sine", 0.15, true)
			wait(0.01)
			item.Visible = false
		end
	end
end

function trigger()
	if not open then
		menu:TweenSize(UDim2.new(1, 0, 6.238, 0), "Out", "Sine", 0.15, true)
		for _, button in pairs(menu:GetChildren()) do
			if button:IsA("TextButton") then
				button.Visible = true
			end
		end
		wait(0.001)
		open = true
	else
		closeFrames()
		wait(0.001)
		for _, button in pairs(menu:GetChildren()) do
			if button:IsA("TextButton") then
				button.Visible = false
			end
		end
		open = false
		Open2 = false
		Open3 = false
		Open4 = false
	end
end

selection.MouseButton1Click:Connect(trigger)

for _, button in pairs(menu:GetChildren()) do
	if button:IsA("TextButton") then
		button.MouseEnter:Connect(function()
			button.BackgroundTransparency = 0.8
		end)
		button.MouseLeave:Connect(function()
			button.BackgroundTransparency = 1
		end)
		button.MouseButton1Click:Connect(function()
			script.Parent.Parent.Parent.CurrentPage.Text = button.Text.." Buttons"
			trigger()
		end)
	end
end

I want this to close out all of the frames

Capture

local function closeFrames()
    for _, item in ipairs(Frame1:GetChildren()) do
        if item:IsA("Frame") then
            item:TweenSize(UDim2.new(1, 0, 0, 0), "Out", "Sine", 0.15, true)
            wait(0.01)
            item.Visible = false
        end
    end
    for _, item in ipairs(Frame2:GetChildren()) do
        if item:IsA("Frame") then
            item:TweenSize(UDim2.new(1, 0, 0, 0), "Out", "Sine", 0.15, true)
            wait(0.01)
            item.Visible = false
        end
    end
    for _, item in ipairs(Frame3:GetChildren()) do
        if item:IsA("Frame") then
            item:TweenSize(UDim2.new(1, 0, 0, 0), "Out", "Sine", 0.15, true)
            wait(0.01)
            item.Visible = false
        end
    end
    for _, item in ipairs(Frame4:GetChildren()) do
        if item:IsA("Frame") then
            item:TweenSize(UDim2.new(1, 0, 0, 0), "Out", "Sine", 0.15, true)
            wait(0.01)
            item.Visible = false
        end
    end
end

This should close out all of the frames when trigger function is called. Please reply if this didn’t work.

It didn’t work, the button didn’t even open.

Could you please check with a print() if the closeFrames function is being fired?

I’m gonna make a video and show yall

Here check it out:

1 Like

Did you check if the print fired?

lemme check it out. I’ll get back to you

Here is what the output said.

It says that in line 3 it couldnt find drop.Menu. You may want to check that. Keep in eye that lua is case-sensitive

Oh Jeez, I think I see the problem… There is no menu in buttons for some reason. I’ll fix that.

Just saw that you have a pic of your workspace here xD. So the variable seems right… Is this a script or local script?

Local Script. But now watch this video because I have another problem.

Ok, so first of all:
Place a task.wait(1) at the beginning of the script. Maybe the script is loaded before the UIs. I will look into your other problem later, since I have to go now.

where at the beginning? Like line 1?

Yes Line 1. So that the Character has time to load until the script runs and checks his elements

Okay done, but it didn’t change anything.

You got any ideas on how to fix this?