Health bar isn't decreasing.

This doesn’t seem to decrease on every collide. Yes I’ve set the sword to have a box collider. But nothing seems to work.

@script ExecuteInEditMode()
var healthTexture : Texture2D;
var healthBorder : Texture2D;
private static var health : int = 100;

function OnGUI () {
	
	GUI.DrawTexture(Rect(0,Screen.height - 600,400,100), healthBorder);

	//Now on top we can put Health Bar texture
	var adjust : int = health * 3;                       //adjusting texture size (width) / health(100)
	GUI.BeginGroup(Rect(135,Screen.height - 565,adjust,15));
	GUI.DrawTexture(Rect(0,0,290,15), healthTexture);
	GUI.EndGroup();
}

/**
    Function to handle collision
*/
function OnTriggerEnter(other:Collider)
{
      health -= 10;
}

if i was you i would do it like this …

c#…

using UnityEngine;
using System.Collections;

public class PlayerHealth : MonoBehaviour {
	public int maxHealth = 100;
	public int curHealth = 100;
	public GameObject Drop;
	public GameObject RagDroll;
	public float healthBarLength;
	public GUIStyle myStyle;
	
	// Update is called once per frame
	void Start ()
	{
		healthBarLength = Screen.width / 3;
	}
	
	void Update () 
	{
	   AddjustCurrentHealth(0);
	}
	
	void OnGUI ()
	{
		GUI.Box(new Rect(10, 32, healthBarLength, 20), curHealth + "/" + maxHealth, myStyle);
	}
	
	public void AddjustCurrentHealth(int adj)
	{
		curHealth += adj;
		
		healthBarLength = (Screen.width / 3) * (curHealth / (float)maxHealth);
		
		if(curHealth < 0)
		{
			Die ();
		}
		if(curHealth > maxHealth)
			curHealth = maxHealth;
		if(maxHealth < 1)
			maxHealth = 1;
	}
	
	
	public void Die ()
	{
		Destroy(gameObject);
		Instantiate(Drop, transform.position, transform.rotation);
		Instantiate(RagDroll, transform.position, transform.rotation);
	}
}

Fixed this by calling the component of the health variable.

function OnTriggerEnter (d:Collider)
{	
	print ("DIE");
	if (animation.Play("attack")== true) {
		GetComponent(Motor).health -= Random.Range(0,10);
	}
}