game.Workspace.Audio.Music.CashBuilderWithSiren:Play()
task.wait(0.5)
for i = 59, 1, -1 do
if i > 10 then
script.Parent.Countdown.Text = "0:"..i
task.wait(1)
elseif i <= 10 then
script.Parent.Countdown.Text = "0:0"..i
task.wait(1)
end
end
So once it hits zero the timer will be 0:00 and the loop will break.
game.Workspace.Audio.Music.CashBuilderWithSiren:Play()
task.wait(0.5)
for i = 59, 1, -1 do
if i > 10 then
script.Parent.Countdown.Text = "0:"..i
task.wait(1)
elseif i <= 10 and i > 0 then
script.Parent.Countdown.Text = "0:0"..i
task.wait(1)
elseif i <= 0 then
script.Parent.Countdown.Text = "0:00"
end
end
ok so the only issue with this is when it hits ten, the text is 0:010, when it should be 0:10
and the countdown never changed the text to 0:00 it stayed at 0:01
game.Workspace.Audio.Music.CashBuilderWithSiren:Play()
task.wait(0.5)
for i = 59, 1, -1 do
if i > 10 then
script.Parent.Countdown.Text = "0:"..i
task.wait(1)
elseif i < 10 and i > 0 then
script.Parent.Countdown.Text = "0:0"..i
task.wait(1)
elseif i <= 0 then
script.Parent.Countdown.Text = "0:00"
end
end
Okay I reviewed the script and made sure to test it and this works for me.
Big apologies just had a long day so I didn’t realize my error.
game.Workspace.Audio.Music.CashBuilderWithSiren:Play()
task.wait(0.5)
for i = 59, 0, -1 do
if i >= 10 then
script.Parent.Countdown.Text = "0:"..i
task.wait(1)
elseif i < 10 and i > 0 then
script.Parent.Countdown.Text = "0:0"..i
task.wait(1)
elseif i <= 0 then
script.Parent.Countdown.Text = "0:00"
task.wait(1)
end
end
I know that this already been solved, but I just wanted to let you know that it’s possible without the use of if-else statements. You could instead use the string.format() function like this: