Please help/fix my scripting (New to Javascript)

So I’ve been getting 3 or 4 compiler errors when I attempt to run my game with the script attached. I’ve tried everything Unity’s error system tells me yet essentially I’m just going in scripting circles trying to follow and fix the errors that it gives me.

For example, one of it’s error messages were:

Assets/SampleAssets/Player_Health.js(43.9): BCE0044: expecting ), found ‘{’.

Nevertheless, here’s the script.

#pragma strict

public var currentHealth : float = 100.0;
public var maxHealth : float = 100.0;
public var minHealth : float = 0.0;
public var drainRate : float = 8.0;
public var hurtPlayer : boolean = false;
GUI.backgroundColor = Color.green;

function Update(){
	
	if (currentHealth <= 0)
	{
	Application.Quit();
	}
}

function OnControllerColliderHit(hit : ControllerColliderHit) {
  
    if (hit.gameObject.tag == "z") {
     currentHealth -= 25;
   }

				
	if(hit.gameObject.name == "healthPack"){
	currentHealth += 15;
	Destroy(hit.gameObject);
	}

	
	if(currentHealth >= maxHealth)
   	{
		currentHealth = maxHealth;
	}
	
	if(currentHealth <= minHealth)
	{
		currentHealth = minHealth;	
	}

function(){
	if(GUI.Button(Rect(10,10,currentHealth,23)
	{
	 "Health: "+currentHealth.ToString;
	}
	
}

Might be better if you post the errors as well so it would make it easier for people to help.

Two thing; in line 42 you’re missing a “)” at the end of the line. Change it to

   if(GUI.Button(Rect(10,10,currentHealth,23), ""))

and this doesn’t work since you’re not assigning it to any variable:

"Health: "+currentHealth.ToString;

you should assign the thing to a string variable like

healthText =  "Health: "+currentHealth.ToString;

where healthText is a string variable.