My Problem now:
As you can see I am referring to the Camera.main.WorldToScreenPoint of my object. It works fine but Unity displays each healthbar twice in the scene. In front of the camera and if I rotate the camera by 180 degrees there are the same healthbars again.
I don’t think there is anything wrong with your script. The problem is that in both cases there wordltoscreenpoint return the same location. These ease solution is to check if the direction towards your object from the cameras forward is less then 90.
var healthbarwidth : int = 80;
function OnGUI() {
var screenPos : Vector3 = Camera.main.WorldToScreenPoint(soldier.position);
var normScreenPos : Vector3 = soldier.position - transform.position;
normScreenPos = normScreenPos.normalized;
GUI.backgroundColor = Color.green;
if(Vector3.Dot(normScreenPos, transform.forward) > 0) //change value of greater to less than if needed
GUI.Button(new Rect(screenPos.x - healthbarwidth/2, Screen.height - screenPos.y - 100, 80, 20),"Health");
}