regenerating health script

hi. would anyone know where i could find a regenerating health script. because i really need one for my game. and if there is one where could i find one that shows a ‘hit’ screen until your health is back up? thanks in advance

I don't usually like writing people's code for them, but I don't have anything to do for the next 5 minutes, so here we go...

public float maxHealth = 100;
public float regeneration = 5;
float health = 100; // Decrease this in your 'damage' script- I won't go into that here

void Start()
{
    health = maxHealth;
}

void Update()
{
    if(health < maxHealth)
    {
        health += regeneration * Time.deltaTime;
        if(health > maxHealth)
        {
            health = maxHealth;
        }
    }
}

void OnGUI()
{
    if(health < maxHealth)
    {
        Color tempColour = GUI.color;
        GUI.color = Color.red;
        GUI.Label(new Rect((Screen.width / 2) - 70, (Screen.height / 2) - 20, 140, 40), "OH NOE THE PAIN");
        GUI.color = tempColour;
    }
}

There you go! I can make a variant which fades the message out depending on how much health you have, but that's a different matter. You may want to define a custom GUIStyle which has bigger writing, and use that instead, but that's not entirely a scripting matter, so I can't really put it here.

EDIT: That bit about not liking to write people's code was a lie.