How to I make the Score only increase not decrease?,Score for my game

Hello,
I am currently developing a 2D platformer and I have Created a score.
The Script I am using is:
scoreText.text = player.position.x.ToString(“0”);
This makes a Text element display the x Position of the player. I really want to have the option for the player to be able to walk both backward and forward, but I don’t want the score to decrease when The player is going backward. Is there any way that the score stays the same when The player moves back, and only Increases once it passes the current score?
Thank you very much

Yes you have to create a seperate variable for it tho. Like float score; try this:

//in player
public float score;

//where you set your text
scoreText.text = player.score.ToString("0");

//after you move your player
if(player.score<player.position.x)
    player.score=player.position.x;

Thank you soo much!