I am trying to make a GUI Box that displays enemy health, but i am getting the error from unity, INVALID DECLARATION TYPE ‘VOID’. This script calls from a different script that has no errors. I will give both. Here is the script that doesn’t work:
#pragma strict
function OnGUI()
{
var box = GUI.Box(Rect(20,20,200,30),"First Enemy Health: " + EnemyHealth.Health);
return box;
if (EnemyHealth.Health <= 0)
{
GUI.Box(Rect(20,20,200,30),"First Enemy Health: 0");
}
}
function ApplyDammage(TheDammage :int)
{
EnemyHealth.Health -= TheDammage;
}
Here is the other script that works(EnemyHealth):
#pragma strict
static var Health = 100;
function Update () {
if (Health <= 0)
{
Destroy (gameObject);
}
}
function ApplyDammage(TheDammage :int)
{
Health -= TheDammage;
}
Please help me fix the error: invalid declaration type ‘void’. Please help!