Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

1 comment

0

Fixed! At the start add "while wait() do" Without Quotation Marks

1 answer

✓ Accepted answer

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'.

5 comments

0

Fairly new to scripting, this is just my attempt.

0

You forgot the "end" to close the "while true do" loop.

0

Added.

0

the lighton = true is needed as It is part of a GUI button

0

Thanks for the help though

This discussion is preserved as it was. New answers, comments, and votes are closed.