Highscore with most far Z position

Hey everyone!

I’m a beginning developer and i have a question. i have made i highscore with help from the video from brackeys: How to make a HIGH SCORE in Unity I want the high score to be the most far Z position my player has come. Does anyone know how to do this?

void Start()
{
highScore.text = PlayerPrefs.GetInt(“HighScore”).ToString();
}

public void SetHighScoreWithZ()
{
     if(transform.position.z > PlayerPrefs.GetInt("HighScore"))
     {
            PlayerPrefs.SetInt("HighScore", transform.position.z);
     }
}

//Attach the script to player