Camera Follow On Y Axis Only

Hi I was wondering a way I can get my camera to only be able to go up on the y axis and not on the x axis. This is for a mobile doodle jump like game. Here is the code I’m using.`

public Transform player;
public Vector3 offset;

// Update is called once per frame
void Update() {
    transform.position = player.position + offset;

    
}

`

void Update() {
Vector3 position = transform.position ;
position.y = (player.position + offset).y;
transform.position = position ;
}