How to increase the life of the player?

Hi all!
I plugged in my palyer life. every time I hit me a lever life.
I want my player is now being increased life by taking a cube and doing so increases my life.

I am using this script to the player.

health control:

var health1 : Texture2D;

var health2 : Texture2D;

var health3 : Texture2D;

var health4 : Texture2D;

static var LIVES = 5;

function Update ()

{

switch(LIVES)

{

   case 4:
        guiTexture.texture = health4;
   break;

case 3:
guiTexture.texture = health3;

break;

case 2:
guiTexture.texture = health2;

break;

case 1:
guiTexture.texture = health1;

break;

case 0:

Application.LoadLevel(0);

   break;

}

}

Firstly, use an Array to tidy up your lives GUI. It will keep your code clean and much more manageable and efficient.

Secondly, you would want to setup a collision on the player that when they collided with the cube, it will run this:

lives +=1;

Add such a script to the trigger or the cube which increases a life that the script in the cube connects to the life script in player and increase it…
For Example:: The script for the cube can be like this:

var lifeAmount = 1;//life to be added to the player
    //Change the playerLife to the name of script attached to the //player
    function ApplyPickup (playerLifeScript : playerLife)
{

switch (lifeAmount)
{
case 0:
   playerLifeScript.AddHealth(lifeAmount);
   break;

function OnTriggerEnter(col : collider) {
var playerLifeScript : playerLife = col.GetComponent(playerLife);
}

And for the player, the script can be named as playerLife…
var health : int = 6;
var maxHealth : int = 6;

function AddHealth (powerUp : int)
{
	health += powerUp;
	
	if (health>maxHealth)// We can only show six segments //in our HUD.
	{
		health=maxHealth;	
	}		
}