Timer that resets based off variable value changing

So, really simple question here:
How do I create a timer that counts down in seconds that will reset the countdown if a bool value changes?

For some more clarification:

Counter counts down let say 10 seconds from 60
A bool value changes to true
script realizes that it has changed values and if it is changed to true will then start counting down back from 60 seconds

I’m not asking for a script here.

I’ve tried many solutions in the past to no avail, most of the things that I did try I couldn’t find a way forward with.

I don’t know, It’s probably really simple but do any of you guys know a general way on how to do it?

1 Like

You might be looking for the Changed function.

1 Like

Yes… that is probably an integral part, but I’m also wondering about following up after the value gets changed and what to do to restart the timer.

Ik you didn’t ask for a script but I will write it out for convienience

local boolvalue = game.ReplicatedStorage.Values.RoundBool
function Timer()
   while true do
      boolvalue.Changed:Once(function()
         if boolvalue then continue end
      end)
      for i = 60,0,-1 do
         if i == 50 then boolvalue = true end
         print(i) -- Replace this with wtv you're using
         wait(1)
      end
   end
end
spawn(Timer)

Basically we’re listening for the bool value change in the loop and if its true then we reset the entire loop.

1 Like

oh, wow thank you lol. I’d known about break for quite some time now but never researched about continue :sob:

1 Like