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.
01 | local BPD = game.Workspace.BasePlate -- Changes the name of BasePlate in the script. |
02 |
03 | wait( 5 ) |
04 | if BPD.BrickColor = = BrickColor.White() then -- If the BasePlate (BPD) is White then, |
05 | wait( 2 ) |
06 | BPD.BrickColor = BrickColor.Yellow() |
07 | wait( 2 ) |
08 | BPD.BrickColor = BrickColor.Black() |
09 | wait( 2 ) |
10 | BPD.BrickColor = BrickColor.Red() |
11 | wait( 2 ) |
12 | BPD.BrickColor = BrickColor.Blue() |
13 | wait( 2 ) |
14 | BPD.BrickColor = BrickColor.Gray() |
15 | wait( 2 ) |
01 | local BPD = game.Workspace.BasePlate -- Changes the name of BasePlate in the script. |
02 |
03 | wait( 5 ) |
04 | if BPD.BrickColor = = BrickColor.new( "White" ) then -- If the BasePlate (BPD) is White then, |
05 | while true do |
06 | wait( 2 ) |
07 | BPD.BrickColor = BrickColor.new( "Yellow" ) |
08 | wait( 2 ) |
09 | BPD.BrickColor = BrickColor.new( "Black" ) |
10 | wait( 2 ) |
11 | BPD.BrickColor = BrickColor.new( "Red" ) |
12 | wait( 2 ) |
13 | BPD.BrickColor = BrickColor.new( "Blue" ) |
14 | wait( 2 ) |
15 | BPD.BrickColor = BrickColor.new( "Gray" ) |
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.
01 | local Part = workspace.Baseplate -- define ( Part=Location) |
02 | local Colors = { BrickColor.Yellow(),BrickColor.Black(), BrickColor.Red(),BrickColor.Blue() } -- Place all your colors in the array |
03 | wait( 5 ) |
04 | if Part.BrickColor = = BrickColor.White() then |
05 | while wait( 2 ) do -- do add a wait() function to prevent crashes |
06 | for i = 1 ,#Colors do |
07 | Part.BrickColor = Colors [ i ] |
08 | end |
09 | end |
10 | end |
Use DangCoolIsReal's idea but I'll make it shorter
1 | local BPD = game.Workspace.BasePlate |
2 | Colors = { BrickColor.Yellow,BrickColor.Black,BrickColor.Red,BrickColor.Blue,BrickColor.Gray,BrickColor.DarkGray,BrickColor.Green,BrickColor.White, } |
3 | while wait() do |
4 | for i = 1 , 8 do |
5 | BPD.BrickColor = Colors [ i ] () |
6 | wait( 2 ) |
7 | end |
8 | end |
01 | local BPD = game.Workspace.BasePlate |
02 |
03 | local Colors = { |
04 | [ 1 ] = BrickColor.Yellow, |
05 | [ 2 ] = BrickColor.Black, |
06 | [ 3 ] = BrickColor.Red, |
07 | [ 4 ] = BrickColor.Blue, |
08 | [ 5 ] = BrickColor.Gray, |
09 | [ 6 ] = BrickColor.DarkGray, |
10 | [ 7 ] = BrickColor.Green, |
11 | [ 8 ] = BrickColor.White, |
12 | } |
13 |
14 | wait( 5 ) |
15 |
Why so many downvotes?