Accessing componenents without defining componenet name?

Hey all,

I have a script that basically shows an enemy bosses life on the HUD, however I wish to change the health bar displayed for different enemies.
The problem is I would rather not create 100 HUD scritps for each individual enemy as that jsut doesn’t seem right.

So what I’m trying to do;

Is have my HUD object, with a HUD script attached.
in the inspector drag what ever enemy i choose, then the HUD will then access the script attached to the enemy and pull out ‘EnemyLives’. thing is I want it to access any script and not a defined one… i dunno if that makes sense.

Yet, in another scene, i can apply another script, and it would work…

so, something like:

private var Enemylives : float;
var McScript : Script; <--- attach gameobject carrying script in inspector. this is where im stuck.

fucntion start(){

Enemylives = McScript.lives;

}

Kinda stuck on this one.

Thanks, josh

Thought I should come back to this question with a solution. Simply, I did the below:

var level : int; //set in inspector
var B : GameObject;
var BSC : Component;

function Start(){

//what level are we in?
	if (level == 1){
		levelOne();
	}
	
	if (level == 12){
	levelTwelve();
	}
}

function levelTwelve(){
		B = GameObject.FindWithTag("enemy12");
		var BS = B.GetComponent(bossTwelveScript);
		BSC = BS;
}

function levelOne(){
		B = GameObject.FindWithTag("enemy1");
		var BS = B.GetComponent(bossOneScript);
		BSC = BS;
}

function Update(){
   	if(BSC.Variable123>=0)
   //do something
}