player damage script help

hello
i have made a script for the health of my player.
but i can’t make a script for te damage can you help me please

this my script

var curHealth : int = 100;
var maxHealth : int = 100;
var healthtext : GUIText;

function Start () 
{
    healthRegen();
}

function Update () 
{
    healthtext.text = curHealth + " / " + maxHealth;

    if(curHealth < 0 ) 
    {
        curHealth = 0;
    }

    if(curHealth > 100) 
    {
        curHealth = 100;
    }

    if(Input.GetKeyDown("e")) 
    {
        curHealth -= 10;
    }
}

function healthRegen () 
{
    for(i=1;i>0;i++) 
    {
        yield WaitForSeconds(0.5);

        if(curHealth < maxHealth) 
        {
            curHealth++;
        }
    }
}

I’m not sure you asked your question in the correct manner… This script you have written works. I press ‘e’, health is subtracted, then regeneration causes health to rebuild…

EDIT: I’ve taken out the for() loop (Thx @fafase):

#pragma strict  

var curHealth : int = 100;
var maxHealth : int = 100;
var healthtext : GUIText;

function Start ()
{
	healthRegen();
}

function Update ()
{
	healthtext.text = curHealth + " / " + maxHealth;
	
	if(curHealth < 0 )
	{
		curHealth = 0;
	}
	
	if(curHealth > 100)
	{
		curHealth = 100;
	}
	
	if(Input.GetKeyDown("e"))
	{
		curHealth -= 10;
	}
}

function healthRegen ()
{
	while(true)
	{
		yield WaitForSeconds(0.5);
		if(curHealth < maxHealth)
			curHealth++;
		yield WaitForEndOfFrame();
	}
}