Health pack will not work

I am trying to add health when a health pack is hit. I have tried to add another if(collision) statement but that didn’t work. I understand that unity has issues with multiple triggers. I am still new to scripting and would really appreciate some help.

Here is my script:
var fullHealth : int = 100;
var curHealth : int = 100;
var curHealth2 : int= 100;
function OnCollisionEnter(collision: Collision) {
if(collision.gameObject.tag == “Enemy”);
curHealth -= 1;
print (“hit”);
}

function Update () {

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

if(curHealth <= 0){
curHealth = 0;
Debug.Log(“You Died”);
}
}

function OnGUI() {
GUI.Label (Rect (25, 60, 100, 20), “”+curHealth);
}

The script you posted is checking collision to see if the object collided with is an enemy and then subtracting health.

In order to add health when colliding with a health pack you want to check for collision with an object tagged “HealthPack” and then add health.

Here is an example of code using a switch statement to determine the response to collisions.

Edit: corrected ToString() method call.

var fullHealth : int = 100; 
var curHealth : int = 100; 
var curHealth2 : int= 100; 

function OnCollisionEnter(collision: Collision) 
{
    switch (collision.gameObject.tag)
    {
        case "Enemy" : 
        curHealth -= 1; 
        print ("hit");
        break;
        
        case "HealthPack" : 
        curHealth += 1; 
        print ("got health");
        break;
    }
}

function Update () 
{

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

    if(curHealth <= 0)
    {
        curHealth = 0; Debug.Log("You Died"); 
    }
}

function OnGUI()
{
    GUI.Label (Rect (25, 60, 100, 20), curHealth.ToString()); 
}