Camera follows player upward in y axis but doesn't follows down when player comes down

Hi,
in my game player bounces upward in y axis and camera follows the player as it bounces up in y axis. But i want my camera to follow the player only when it bounces up but remain static when the player bounces down. here is the script i have used till now.

public Transform player;

// Update is called once per frame
void Update () {

	transform.position = new Vector3 (transform.position.x,player.position.y, transform.position.z);
}

}

If I understand correctly what you’re trying to do, you should just add a check to see if the player is moving up or down and if up apply the new value. If not just do nothing.

void Update()
{
   if(transform.position.y < player.position.y)
       transform.position = new Vector3 (transform.position.x,player.position.y, transform.position.z);
}