Where is my HP Bar?

Start learning GUI. Trying to make HP bar. Some wrong?

using UnityEngine;
using System.Collections;

public class playerHP : MonoBehaviour {
	public int maxHealth = 100; //Max HP
	public int curHealth = 100; //Current HP
	
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	
	void onGUI () {
		GUI.Box(new Rect(10, 10, Screen.width / 2 / (maxHealth / curHealth), 10), " "); //Must show HP bar.. But I don't see it ;(
		
	  }
	
}

Using only integers in division results in integer division. Use floats, or at least cast to float while dividing, so you can have float division instead.

I see that it’s from BurgZerg Arcade.
Maybe try original script? It works fine for me.

using UnityEngine;
using System.Collections;

public class PlayerHealth : MonoBehaviour {
public int maxHealth = 100;
public int curHealth = 100;

public float healthBarLength;

// Use this for initialization
void Start () {
healthBarLength = Screen.width / 2;
}

// Update is called once per frame
void Update () {
AddjustCurrentHealth (0);
}
void OnGUI(){
GUI.Box(new Rect(10, 10, healthBarLength, 20), curHealth + "/" + maxHealth);
}

public void AddjustCurrentHealth(int adj) {
curHealth += adj;

if(curHealth < 0)
curHealth = 0;

if (curHealth > maxHealth)
maxHealth = 1;

healthBarLength = (Screen.width / 2) * (curHealth / (float)maxHealth);
}

}

i’m already found problem. I used onGUI () not OnGUI ()