I looked on the wiki, there was an article on "Loops", but I couldn't get it to work. Anyways, here is the script I tried:
for i = 1, math.huge do game.Workspace.Part1.BrickColor = "Bright red" wait(1) game.Workspace.Part2.BrickColor = "Bright red" game.Workspace.Part1.BrickColor = "Black" wait(1) game.Workspace.Part3.BrickColor = "Bright red" game.Workspace.Part2.BrickColor = "Black" wait() break end
the for loop is for repeating a set number of times
ie:
for i = 1,10 do print(i) wait() end
would loop 10 times. math.huge is infinity, or as close as infinity as roblox lua allows. so if your trying to make it go on forever, use a while loop.
while true do wait() -- dont crash print("hi") end
you would want to use break when specific standards meet.
while true do wait() print("waiting on at least 2 players") if #game.Players:GetChildren() > 1 then print("Enough players!") break end end
but in that case, you would want to use something more effective to loop only while true.
while #game.Players < 2 do wait() print("waiting on at least 2 players") end print("Enough players!")
hope this helped ;)
while true do wait(1) game.Workspace.Part1.BrickColor = "Bright red" wait(1) game.Workspace.Part2.BrickColor = "Bright red" game.Workspace.Part1.BrickColor = "Black" wait(1) game.Workspace.Part3.BrickColor = "Bright red" game.Workspace.Part2.BrickColor = "Black" end
Just add while true do and an extra end to your script and you're golden. Example:
while true do for i = 1, math.huge do game.Workspace.Part1.BrickColor = "Bright red" wait(1) game.Workspace.Part2.BrickColor = "Bright red" game.Workspace.Part1.BrickColor = "Black" wait(1) game.Workspace.Part3.BrickColor = "Bright red" game.Workspace.Part2.BrickColor = "Black" wait() break end end
That would loop infinitely.