Hello guys! I want to loop all those elements, but I want the loop to be done in hierarchical order, because I need to apply a color to each one, one after the other (like a domino effect).
3 Likes
Oh, I came up with an Idea:
local table = {"1", "2", "3", "4", "5", "6"}
for _, v in ipairs(table) do
line1:FindFirstChild(v).Color = Color3.new(0, 0, 0)
end
1 Like
But anyway I want to know if there is another way to do this.
You could use a modulous operator, if you want to loop forever you could use this script.
local index = 1
while true do
local item = line1:FindFirstChild(tostring(index))
-- do thing with item
index = (index % 6) + 1
task.wait()
end
If you do not need to repeat loops then we can remove the modulous operator and just use numbers counting up.
local index = 1
while index < 7 do
local item = line1:FindFirstChild(tostring(index))
-- do thing with item
index += 1
end
1 Like
Does GetChildren not use heirarchal order?
for _, item in ipairs(line1:GetChildren()) do
-- do thing in item
end
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.