How do I create a high score system in my game?

My game has you driving around avoiding enemy cars for as long as you can. I want my game to have a score saving system that shows how long you survived. I already have the timer implemented in. The timer script I am using is as follows.

var time : int = 1;

function Start () {
	while(time != 0) {
		yield WaitForSeconds(1);
		time = time + 1;

function OnGUI () {
	GUI.Box(Rect(0, 0, 100, 30),"Time: " + time);

simply create another variable called var highScoreTime : int; and then when you die or lose, set highScoreTime = time. Then when the game restarts, don’t overwrite the highScoreTime variable. However, this will be lost as soon as you stop playing the game. If you want it to save it permanently you’ll need to do some extra work such as implementing this XML Save/Load package: or just google “Save/Load in Unity” and you’ll see plenty of various solutions with different degrees of difficulty.