how do i make an object follow another object but only on the y axis?

Help i tried using this but that didn’t work

    float PlanePosition = Plane.transform.position.y;
    float ThisPosition = transform.position.y;
   Vector3 relativePos = new Vector3 (0.0, PlanePosition - ThisPosition,0.0) ;
    Quaternion rotation = Quaternion.LookRotation(relativePos);
    transform.rotation = rotation;

Your code is not clear enough, but basically, you just need to get the object which need to be followed position y. Then the change the transform.position of the following game object only with y you’ve got.

The LookRotation function can only get the rotation of looking at target which you can refer to here.

To change your position you need to use this.transform.position = target.transfrom.position.

thanks the LookRotation function help! got it working!