GUI box not moving with game object on X axis

Hey,

I am trying to create a health bar above a spaceship in a 2d spaceshooter. Right now I just need to create a box and move it with the player. I found WorldToScreenPoint() which should work althought the box moves only on the Y axis, why is that?

This code is in Player.js attached to the ship gameobject

// Gui render
functionOnGUI(){

varPlayerPosition:Vector2=Camera.main.WorldToScreenPoint(transform.position);

print(PlayerPosition.x);

GUI.Box(newRect(PlayerPosition.x,PlayerPosition.y,200,200),‘Test’);

}

The print shows the changed position but the box only moves up and down.

Thanks!

Bump :frowning: