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

How do I make my script repeat? ( I have read some of the other threads but they dont help)

Asked by 4 years ago

Ive tried tried my usual way of scripting and it seemed to work but It is not working, it does the script once but ends after one go.

Here is the script:

while true do
if lighton == false then

wait(.3)
one.BrickColor = BrickColor.new("Really red")
wait(.3)
one.BrickColor = BrickColor.new("Institutional white")
wait(.3)
two.BrickColor = BrickColor.new("Really red")
wait(.3)
two.BrickColor = BrickColor.new("Institutional white")
wait(.3)
three.BrickColor = BrickColor.new("Really red")
wait(1)
three.BrickColor = BrickColor.new("Institutional white")
lighton = true
end

end

0
Fixed! At the start add "while wait() do" Without Quotation Marks StraussKapieren 2 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

The reason in which your script isn't working is that the if statement is only activated once as the lighton variable is true. When the script finishes, you change the variable lighton back to true, meaning the if statement isn't going to be used and ignore all of the brick colours changing. The way you can do this is by removing the if statement, as it technically has no reason to be there.

while true do
    --if lighton == false then (This if statement also isn't needed)

    wait(.3)
    one.BrickColor = BrickColor.new("Really red")
    wait(.3)
    one.BrickColor = BrickColor.new("Institutional white")
    wait(.3)
    two.BrickColor = BrickColor.new("Really red")
    wait(.3)
    two.BrickColor = BrickColor.new("Institutional white")
    wait(.3)
    three.BrickColor = BrickColor.new("Really red")
    wait(1)
    three.BrickColor = BrickColor.new("Institutional white")
    --lighton = true (This isn't needed)
end

Apologies for the incorrect formatting, I am on mobile as I can't do 'Tab', if this doesn't work simply just comment and if my answer is correct please click 'Accept answer'.

0
Fairly new to scripting, this is just my attempt. RyanTheLion911 195 — 4y
0
You forgot the "end" to close the "while true do" loop. RSASDSA 72 — 4y
0
Added. RyanTheLion911 195 — 4y
0
the lighton = true is needed as It is part of a GUI button StraussKapieren 2 — 4y
0
Thanks for the help though StraussKapieren 2 — 4y
Ad

Answer this question