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

How could I shorten this script down to make it easier?

I want to make a countdown script, but I think it's going to take me over an hour to finish. How could I shorten this?

while true do

script.Parent.Text = "7:00"
wait(1)

script.Parent.Text = "6:59"
wait(1)

script.Parent.Text = "6:58"
wait(1)

-- Right down to 0:00

Thanks for your help :)

1 answer

You can use a for loop. It's pretty awesome.

NumberOfSeconds = 420

for i = NumberOfSeconds, 0, -1 do
	script.Parent.Text = i
	wait(1)
end

For every second, the text property will display the current number of seconds.

You can also add some math stuff so it would display "7:00" instead of "420."

3 comments

0

Good thinking :) thanks :D

0

Wait, I just tried it, I need a countdown. It's going up, not down. How can I edit the script to solve that?

0

Updated; all I've done is make the initial variable set to the number of seconds, and the final variable to 0. I have it go down by -1.

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