In order to set new High Score, current score must be larger than last high score. We check that in “OnDisable()” function. If current score is larger than high score value in PlayerPrefs, we simply set current score as new HighScore.
Keep in mind that I commented out that line of code in Start function, because I don’t know do you have to create key before you can use it in Player Prefs, so I just used it to set it up on first run.
If you run that code and disable/enable your gameObject, you will see that high score has new value each time.