Trying to disable all frames under a folder, not working

I’m trying to disable all of the frames under a folder, however running :GetChildren() and trying to make them all visible = false doesn’t seem to be working.

Script:

script.Parent.MouseButton1Click:connect(function()
	script.Parent.Parent.Parent.Parent.Customs.Visible = false
	script.Parent.Parent.Parent.Parent.Knights.Visible = false
	script.Parent.Parent.Parent.Parent.Order.Visible = false
	script.Parent.Parent.Parent.Parent.Humans.Visible = false
	script.Parent.Parent.Parent.Parent.Main.Visible = false
	
	local desc = script.Parent.Parent.Parent.Parent.Descriptions.Order
	local frames = desc:GetChildren()
	frames.Visible = false
end)

this is where the frames are

image

frames is an Array as GetChildren() returns an Array of Instances, use a for loop to iterate through them

1 Like

:GetChildren() returns an array of the children. You will need to loop through that array using a for loop and set the visibility of each frame.

for _, frame in ipairs(desc:GetChildren()) do
    frame.Visible = false
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.