Interval.

I’ve tried coorutines, didn’t help.
Tried using time.Time, didn’t help.

I’m trying to get a variable to increase a certain amount every couple seconds while colliding with something, but it just spazzes out and throws the variable to zero.

how would I turn this code into something that decreases Health every couple seconds WHILE colliding with whatever.

function OnCollisionStay(collision : Collision) 
{
	
	if (collision.gameObject.tag == "Enemy"  invincible == false) 
	{	

	 	Health -= 10;

	 	
	}
}

You could do this
var Wait : float;
var MaxTime : float = 10.0;
function Update()
{
Wait -= Time.deltaTime;
if(Wait <= 0)
Wait = MaxTime;
}

function OnCollision…(…)
{
if(…)
{
if(Wait == 0)
{
Health -= 10;
}
}
}

Your problem is that OnCollisionStay will run every frame, and in your editing environment, if you don’t lock your frame rate, that might be, say, 200 frames per second, so 200 times per second your Health will be decremented by 10.

Try something like this:

var timeSinceLastDecrement : float = 0;

function OnCollisionStay(collision: Collision)
{
    timeSinceLastDecrement += Time.deltaTime;
    if (collision.gameObject.tag == "Enemy"  invincible == false  timeSinceLastDecrement > 1.0f)
    {
        Health -= 10;
        timeSinceLastDecrement = 0;
    }

}

Which will decrement your health by 10 points once per second.

This worked. Thanks a lot.