GUI.Label error.

Hello one and all!

I have started again with my enemy AI and Health script.

I’m trying to use GUI’s (such as GUI.Label) to create a visual enemy health, however I always get the error of:

Assets/EnemyAI.js(41,26): BCE0023: No appropriate version of ‘UnityEngine.GUI.Label’ for the argument list ‘(UnityEngine.Rect, System.Type)’ was found.

I was wondering why this is happening?

Here is my script:

var health = 10;
var TakeDamage : boolean = false;
var fullhealth = Texture;

function OnTriggerEnter(other : Collider)
{
	if(other.tag == "Player")
	{
		TakeDamage = true;
	}
}

function OnTriggerExit(other : Collider)
{
	if(other.tag == "Player")
	{
		TakeDamage = false;
	}
}

function Update()
{
	if(TakeDamage)
	{
		if(Input.GetButtonDown("Fire1"))
		{
			health -= 1;
		}
	}
	if(health <= 0)
	{
		health = 0;
		Destroy(gameObject);
		Debug.Log("Enemy is dead!");
	}
}

function OnGUI () {
	if(health >= 10)
	{
		GUI.Label(Rect(10,40,100,100),fullhealth);
	}
}

So basically if the health is equal to or more than 10, it will display the fullhealth texture.

Thanks in advance!

Line 3 should be:

var fullhealth : Texture;

…with a ‘:’ not an ‘=’.