Help with Health System Using GUI Texture (Scripts Here)

Alright I’m totally stuck and I can’t figure it out. I’m trying to make it so that every time I get hit I loose health from the health bar, but every time I get hit nothing happens, I also made a dead zone so if the character falls off you loose one health piece. This is what I have so far tell me what needs fixing if you can, there’s no apparent errors, except maybe a logic error because I must have set something wrong.

First code is the movement and getting hit

Second is the GUI Health script

//Getting Hit Script

//Easy movement on the x-z plane.
var speed = 10.0;
var rotationSpeed = 100.0;
private var dead = false;


//Getting Hit
var tumbleSpeed = 0;
var decreaseTime = 0.01;
var decayTime = 0.01;
static var gotHit = false;
private var backup = [tumbleSpeed, decreaseTime, decayTime];


function OnControllerColliderHit(hit : ControllerColliderHit)
{
	if(hit.gameObject.tag == "fallout")
	{
		dead = true;
		//HealtControl Here
		HealthControl.LIVES -= 6;
		
	}


}
function Update () {
	// Get the horizontal and vertical axis.
	var translation = Input.GetAxis ("Vertical") * speed;
	var rotation = Input.GetAxis ("Horizontal") * rotationSpeed;

	// Make it move 10 meters per second instead of 10 meters per frame...
	translation *= Time.deltaTime;
	rotation *= Time.deltaTime;

	// Move translation along the objects z-axis
	transform.Translate (0, 0, translation);
	// Rotate around our y-axis
	transform.Rotate (0, rotation, 0);
}

function LateUpdate()
{
	if(dead)
	{
		transform.position = Vector3(0,4,0);
		gameObject.Find("Main Camera").transform.position = Vector3(0,4,-10);
		dead = false;
	}
	
	if(gotHit)
	{
		if(tumbleSpeed < 1)
		{
			tumbleSpeed = backup[0];
			decreaseTime = backup[1];
			decayTime = backup[2];
			gotHit = false;
		}
		else
		{
			//were hit spin around character
			transform.Rotate(0, tumbleSpeed * Time.deltaTime,0, Space.World);
			tumbleSpeed = tumbleSpeed-decreaseTime;
			decreaseTime += decayTime;
		}
	}
  }
//GUI_Health Script
var health1 : Texture2D; //one live left
var health2 : Texture2D; //two live left
var health3 : Texture2D; //three live left
var health4 : Texture2D; //four live left
var health5 : Texture2D; //five live left
var health6 : Texture2D; //full left

static var LIVES = 1;

function Update () 
{
	switch(LIVES)
	{
		case 6:
			guiTexture.texture = health6;
			break;
			
		case 5:
			guiTexture.texture = health5;
			break;
			
		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:
			//gameover script here
			break;
	}

}

Anyone at all…

Well, I don’t know if I’m missing something, but the “if” statement doesn’t seem to do anything if the tag is not equal to “fallout”. Is there any other code that you’ve missed out here?

Thanks for the respond, but no there doesn’t appear to be anything that I’m missing, but I decided to scrap this script and used the fps tutorial scripts health system and everything is working fine. Only problem is that I want to customize my health bar, but if I remove any part of the GUIs then I get error because all the referencing scripts are also trying to access the GUIs. Could you or anyone else help me with that? Everything works fine with my game I just want to get rid of the Rocket and Ammo GUIs and just have the health bar that I can customize. If anyone knows what I can do that’d be really appreciated.

I can post a web player of my game if you want to see for yourself. Thanks

There probably isn’t much you can do about that except for removing the references to the GUI from the code or else moving the GUI elements offscreen so they are still “displayed” but invisible.

What customisation do you need for the health bar? How do you want it to look?