How can I create a timer that stops when a value = 0?
I want to make a timer where when a value = 0 then it resets the timer. Essentially when the value = 1 it starts the timer and counts down from 20 to 0 but if the value = 0 then it stops and resets the timer and doesn't count down. How can I go about doing this?
Here's something that might help:
(Script)
value.Changed:Connect(function() if value.Value == 1 then for i = 20,0,-1 do timer.Value = i end elseif value.Value == 0 then timer.Value = 20 end end)
I don't know how the timer is set up, but right here I made it a value, which should be the case for a timer working in a server script and make a local script update the text of the timer.
I hope this helped!
Well I figured it out myself:
Script:
for i = 20,0,-1 do if value.Value >= 1 then wait (1) timer.Value = i elseif value == 0 then timer.Value = 20 end end