What I want is when the script runs and everything finishes, I want it to repeat itself forever and keep starting from beginning one finished.
local BPD = game.Workspace.BasePlate -- Changes the name of BasePlate in the script. wait(5) if BPD.BrickColor == BrickColor.White() then -- If the BasePlate (BPD) is White then, wait(2) BPD.BrickColor = BrickColor.Yellow() wait(2) BPD.BrickColor = BrickColor.Black() wait(2) BPD.BrickColor = BrickColor.Red() wait(2) BPD.BrickColor = BrickColor.Blue() wait(2) BPD.BrickColor = BrickColor.Gray() wait(2) BPD.BrickColor = BrickColor.DarkGray() wait(2) BPD.BrickColor = BrickColor.Green() wait(2) repeat end
local BPD = game.Workspace.BasePlate -- Changes the name of BasePlate in the script. wait(5) if BPD.BrickColor == BrickColor.new("White") then -- If the BasePlate (BPD) is White then, while true do wait(2) BPD.BrickColor = BrickColor.new("Yellow") wait(2) BPD.BrickColor = BrickColor.new("Black") wait(2) BPD.BrickColor = BrickColor.new("Red") wait(2) BPD.BrickColor = BrickColor.new("Blue") wait(2) BPD.BrickColor = BrickColor.new("Gray") wait(2) BPD.BrickColor = BrickColor.new("Dark gray") wait(2) BPD.BrickColor = BrickColor.new("Green") wait(2) end end
should work.
There are many loops in lua such as : For,While, and Repeat loops, In this case, you want to loop forever, use the While
loop, this loop continues looping until the condition is nil
or false.
local Part=workspace.Baseplate -- define ( Part=Location) local Colors={BrickColor.Yellow(),BrickColor.Black(), BrickColor.Red(),BrickColor.Blue()}-- Place all your colors in the array wait(5) if Part.BrickColor==BrickColor.White() then while wait(2) do -- do add a wait() function to prevent crashes for i=1,#Colors do Part.BrickColor=Colors[i] end end end
Use DangCoolIsReal's idea but I'll make it shorter
local BPD = game.Workspace.BasePlate Colors = {BrickColor.Yellow,BrickColor.Black,BrickColor.Red,BrickColor.Blue,BrickColor.Gray,BrickColor.DarkGray,BrickColor.Green,BrickColor.White,} while wait() do for i = 1, 8 do BPD.BrickColor = Colors[i]() wait(2) end end
local BPD = game.Workspace.BasePlate local Colors = { [1] = BrickColor.Yellow, [2] = BrickColor.Black, [3] = BrickColor.Red, [4] = BrickColor.Blue, [5] = BrickColor.Gray, [6] = BrickColor.DarkGray, [7] = BrickColor.Green, [8] = BrickColor.White, } wait(5) while true do for i = 1, #Colors-1 do BPD.BrickColor = Colors[i]() wait(2) end BPD.BrickColor = Colors[#Colors]() wait(2) end
Why so many downvotes?