So I am looping through frames and I want to return all the frames given and pack them into a table so I can access them via a variable, so how exactly would I do that?
You can use GetChildren to Get all the children of a cerain Instance.
Than use for i,v in pairs() do, to cycle through them all.
local Frames = Gui:GetChildren()--Returns{Frame1,Frame2,Frame3,Frame4}
for index, variable in pairs(Frames) do
variable.Visible = false--ex changing frame property
end
If you are unsure about for i,v in pairs loops, than check out:Tables | Documentation - Roblox Creator Hub or
In Pairs Loops (i, v in pairs) - Roblox Beginner Scripting #18 - YouTube
2 Likes
function getFrames(instance)
local a = {}
for i,v in pairs(instance:GetChildren()) do
if v:IsA("Frame") then
a[#a+1] = v
end
end
return a
end
local frames = getFrames(script.Parent) -- the part to look for frames in
2 Likes