# Timer (problem)

**URL:** <https://forum.kirupa.com/t/timer-problem/84286>\
**Category:** programming\
**Created:** [March 26, 2005, 12:07am UTC](https://forum.kirupa.com/t/timer-problem/84286 "2005-03-26T00:07:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)\
**Post date:** [March 26, 2005, 12:07am UTC](https://forum.kirupa.com/t/timer-problem/84286/1 "2005-03-26T00:07:50Z")

</div>

I have this code for my timer, it counts down alright. BUT it is very buggy it most commonly counts down by 2 when it is meant to count down by one:\*( I have even watched my brother play our game and it went fron 20 to 7!!! any help would be greatly appreciated. If anyone could even give a code that counts down in minutes and seconds would be majorly appreciated. But yeh, I don’t know what is causing it so please help a man in need LOL:D

```auto
 
var cur_timer = 180;
function timer() {
if (cur_timer > 0) {
cur_timer--;
} else {
cur_timer = "Time up!";
gotoAndPlay("43")
clearInterval (time_interval);
}
}
time_interval = setInterval(timer, 1000);

```

EDIT: OK i have figured it out… It is when you die it goes to a different frame and then it comes back to the original frame while the interval is still going, so if you die 2 times it would go down 2 times a second, you die 3 times it goes down 3 times per second etc. However i cant figure out how to stop it anyone help?
