HP heal after set time not working (setInterval();)

You guy’s have saved me once not to long ago, I could use that again here :smiley:

So, my problem is I have set up a script for a HP bar, and now I want to set up a script that will replenish the character’s HP after a set amount of time. (IE. 2 seconds.) I was reading about setInterval(); and clearInterval(); and it seemed to be the best thign to use, but I can’t get it to work.

here is my code

CurrHP = 10;
HP = 50;
clearInterval(autoheal);
var autoheal = setInterval(function () {
    if (CurrHP<HP) {
        CurrHP += 5;
    }
}, 2000);
trace(CurrHP);

any help would be great!

Thanks in advance,
-Naezo