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

Could someone help me out on why this countdown from 300 to zero won't work?

When I click a button in my game's workspace, I made it set a value to 300 (this works fine) however the countdown script that I put inside the value does not work and I can't understand why. I want it to countdown from whatever number it is at until it is 0. I have tried repeat until the value equals 0 and the countdown just keeps going.

while true do
	if script.Parent.Value > 0 then
		script.Parent.Value = script.Parent.Value - 1
		wait(1)
	end
end

1 comment

0

you can make something like that: if value = 0 then remove the countdown.

1 answer

✓ Accepted answer

You should use For Loops.

for i = 300, 0, -1 do -- Start / End / Increment
	script.Parent.Value = i
	wait(1)
end

This will count down from 300 to 0 every second.

1 comment

0

I will try this in the morning to see if it works as I have to go to sleep now, but thank you in advance!

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