Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can you fix this script?

Asked by
awfulszn 394 Moderation Voter
9 years ago

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

4 answers

Log in to vote
0
Answered by
wackem 50
9 years ago
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.

Ad
Log in to vote
1
Answered by
woodengop 1134 Moderation Voter
9 years ago

Loop

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
0
Use while wait() do, it's the same has while true and wait() do but shorter EzraNehemiah_TF2 3552 — 9y
0
Or even better, while wait(2) do; That way you can remove the wait(2) from the other segment DigitalVeer 1473 — 9y
Log in to vote
0
Answered by 9 years ago

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
Log in to vote
-1
Answered by 9 years ago
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?

0
I have to downvote because your 23 lined script can actually be 8 lined EzraNehemiah_TF2 3552 — 9y

Answer this question