gameobject.transform.position not working correctly

hey guys, so i try to move my object to certain coordinat, heres the code

if (gameObject.transform.position.x <= -49.7f )
        {
            gameObject.transform.position = new Vector3(49.08f, 1f, 0.0f);
        }

while the object correctly move to the X coordinat i wanted, but not the Y coordinat, it always move to 0.404 on Y coordinat, it drives me mad, i already try everything but no avail, hope anyone can help

edit :

heres the complete script

void Update ()
    {
        this.gameObject.transform.Translate(Vector3.left * platspeed * Time.deltaTime);

        if (gameObject.transform.position.x <= -49.7f )
        {
            gameObject.transform.position = new Vector3(49.08f, 1f, 0.0f);
        }
  }

Is it the child of another Game Object? Could try gameObject.transform.localPosition

I am having the same issue with a similar piece of code.

In fact, if I do the following:

gameObject.transform.position = new Vector3 (0.0f, 0.0f, 0.0f);

The object moves!! (even though the object started at (0,0,0).

Can anyone help?

For anyone having this issue try using “transform.TransformPoint(Vector3.zero)” instead of using “transform.position”. It returns the object’s position in world space(as"transform.position" should do). This saved me after days of trial and error.