HealthRegeneration script only works when health < 0

I found this HealthRegeneration script in another post, but i cannot seem to get it to work, it looks like this:

var CurHealth : int = 100;
var MaxHealth : int = 100;
var RegenPrSec : float = 0.10;

function Update() {
    regenerate();

    if (Input.GetKeyDown("i")) {
       	takeDamage();
    }
}

function regenerate() {
	if (CurHealth < MaxHealth) {
		CurHealth += RegenPrSec * Time.deltaTime;
	}
}

As far as I can see there is no reason for it to start regenerating when below 0 and it also only goes up to 0. I don’t know much about Time.deltaTime could that be the problem?

The problem is you are mixing ints and floats.

var CurHealth : float = 100;
var MaxHealth : float = 100;
var RegenPrSec : float = 0.10;
 
function Update() {
    regenerate();
 
    if (Input.GetKeyDown("i")) {
        takeDamage();
    }
}
 
function regenerate() {
    if (CurHealth < MaxHealth) {
        CurHealth += RegenPrSec * Time.deltaTime;
    }
    Debug.Log( "CurHealth as float" + CurHealth );
    Debug.Log( "CurHealth as int" + parseInt( CurHealth ) );
}

Also function names should really start in a capitol, and variables should start in lowercase. Use lowercase/camelCase for variables, Capitols for functions.