I have this code:
local outter = game.Workspace.all.outter:GetChildren() local second = game.Workspace.all.second:GetChildren() local third = game.Workspace.all.third:GetChildren() local last = game.Workspace.all.last:GetChildren() local x = 0 while true do for i,v in pairs(outter) do spawn(function() v.BrickColor = BrickColor.new("Really red") v.Material = "Neon" wait(0.5) v.BrickColor = BrickColor.new("Really black") v.Material = "SmoothPlastic" end) end wait(0.5) for b,n in pairs(second) do spawn(function() n.BrickColor = BrickColor.new("Really red") n.Material = "Neon" wait(0.5) n.BrickColor = BrickColor.new("Really black") n.Material = "SmoothPlastic" end) end wait(0.5) for h,j in pairs(third) do spawn(function() j.BrickColor = BrickColor.new("Really red") j.Material = "Neon" wait(0.5) j.BrickColor = BrickColor.new("Really black") j.Material = "SmoothPlastic" end) end wait(0.5) for o,p in pairs(last) do spawn(function() p.BrickColor = BrickColor.new("Really red") p.Material = "Neon" wait(0.5) p.BrickColor = BrickColor.new("Really black") p.Material = "SmoothPlastic" end) end wait(0.5) end
To make it repeat, I tried doing this
local x = 0 while true do repeat until x == 2 --code x = x+1
I thought that if I did this, that once the whole code ran, it would add 1 to x. After it did thise twice so that x == 2, then the code would just stop. But it didn't work. Any ideas? All help is appreciated!
Use a for loop:
for i = 1,2 do --code end