trying to use Vector3.MoveTowards with just y axis

Im trying to smoothly move an enemy along the y axis to the players y axis position. Here is that bit of code:

transform.position = Vector3.MoveTowards(transform.position, player.position.y, moveSpeed * Time.deltaTime);

If there is something im missing I appreciate your help. If it isnt possible to accomplish this with my current method is there a diffrent way of acomplishing my goal

I don’t think you can blatantly access the y position of the transform like that… Try this instead :

Vector3 TargetPos = new Vector3(tranform.position.x, Player.transform.position.y,  transform.position.z);
transform.position = Vector3.MoveTowards(transform.position, TargetPos, moveSpeed * Time.deltaTime);