I trying to make the fires light up in order. "Fires" is a model with 14 parts named 1 to 14. even named to 1,14 it doesn't make it in order
for i,b in ipairs(copy.Fires:GetChildren()) do local fire = b.Middle.Fire fire.Enabled = true wait(1) end)
I thought using "ipairs" would work. but still ignoring the order, why?
Sometimes the children are added in a shuffled order. If your children are named from 1 to 14, why not use a generic for loop with an integer?
for i=1,14 do copy.Fires:FindFirstChild(tostring(i)).Middle.Fire.Enabled = true wait(1) end
You can use for i=1,(ammount) ... end
. but i maked a simple script for detect fires, and delay
You can see of For loop in roblox wiki: For - Wiki
Here is the script:
-- Name the parts with 1, 2, 3, 4 ... local copy = script.Parent.Copy -- Location of folder local v = 0 -- Do not change for i=1,#copy.Fires:GetChildren() do -- For loop to make a delay v = v + 1 -- Add 1 for the value if copy.Fires[v] ~= nil then -- if item not nil if copy.Fires[v].Middle:FindFirstChild("Fire") then -- If find fire if copy.Fires[v].Middle.Fire.Enabled == false then -- If fire not enabled copy.Fires[v].Middle.Fire.Enabled = true -- Enable fire end end else break; -- End script. end wait(1) -- Delay time end
Or you can simple use:
-- Name the parts with 1, 2, 3, 4 ... local copy = script.Parent.Copy for i=1,#copy.Fires:GetChildren() do if copy.Fires:FindFirstChild(tostring(i)) then if copy.Fires[i].Middle.Fire.Enabled == false then copy.Fires[i].Middle.Fire.Enabled = true end end wait(1) end
Why did I make this code difficult instead of using [i]? for me I tried with [i] and was not in any way in order so I decided to do this.
Hope it helped :D