problem with lowering health

ok i am having a problem lowering my players heath when a zombie is attacking heres my scripts can anyone help please

  1. DestroyOnHit

#pragma strict
#pragma implicit
#pragma downcast

class DestroyOnHit extends MonoBehaviour
{
public var hitsToDestroy : int = 1;
public var destructionParticles : GameObject;
public var destroyOnExplosion : boolean = true;
public var destroyParent : boolean = true;

function Start()
{
gameObject.layer = 11;
}

function Destruct()
{
if(destroyOnExplosion)
{
DestroyObject();
}
}

function Hit(hit : RaycastHit)
{
hitsToDestroy–;

if(hitsToDestroy <= 0)
{
DestroyObject();
}
}

function DestroyObject()
{
if(destructionParticles != null)
{
GameObject.Instantiate(destructionParticles, transform.position, Quaternion.identity);
}

if(destroyParent)
{
if(transform.parent != null)
{
Destroy(transform.parent.gameObject);
}
else
{
Destroy(gameObject);
}
}
else
{
Destroy(gameObject);
}
}
}

Following is the zombies script

var damageDone : int;

function OnTriggerEnter( other : Collider ) {
if ( other.GetComponent(DestroyOnHit) ) {
other.GetComponent(DestroyOnHit).hitsToDestroy += damageDone;
}
}

I am sleepy, but what I think you need to do is this :

if (other.gameObject.GetComponent(DestroyOnHit))

GetComponent is an element of GameObject not collider. You are trying to use GetComponent on Collider which doesn’t work. If I was not so sleepy I would be able to explain it better.

lol thank you i think i understand. i am sleepy to

one question does a tag go there? if (other.gameObject.GetComponent(does tag go here?))

tag is a member of GameObject so it would just be other.gameObject.tag

Tomorrow when you are not sleepy can you explain more lol because i am trying so many different thing and they are not working.

http://forum.unity3d.com/threads/65111-Sharing-Variables-Across-Scripts

This will explain it I believe.