Help With Setting High Score Float C#

I’ve tried a number of different things and I can’t figure this one out either. Now I’m just confusing myself and doing more harm than good, and I was hoping someone else could lend a hand. I figured out how to save total time in this thread, http://forum.unity3d.com/threads/241060-Help-With-Saving-Time-Score-in-Player-Prefs-c , but now I’d like to save the Best / Highest Time as a high score and I can’t seem to figure it out. Can someone point me in the right direction using c#, I’ve tried a number of things that I found in threads here and I know I’m doing something wrong.

Here is my code:

using UnityEngine;
using System.Collections;

public class DistanceCS : MonoBehaviour {
	
	public float runTime; ;
	public float bestTime;

	void Start() {
				PlayerPrefs.GetFloat ("runTime", runTime);
				PlayerPrefs.GetFloat ("bestTime", bestTime);
				if (PlayerPrefs.GetFloat ("runTime") > bestTime) {
						bestTime = runTime;
				} else
				bestTime = bestTime;
		}
	
	void OnDestroy() { // Set when my player dies


		PlayerPrefs.SetFloat ("runTime", Time.timeSinceLevelLoad);
		PlayerPrefs.SetFloat ("bestTime", bestTime);
		
		//var savedTime = PlayerPrefs.GetFloat ("runTime");
	//PlayerPrefs.SetFloat ("runTime", savedTime + Time.timeSinceLevelLoad);
	//Debug.Log (PlayerPrefs.GetFloat ("runTime"));
       // ^ I had used these before to save the total time
	}
	
	void OnGUI () {
		guiText.text = "Time: " + Time.timeSinceLevelLoad.ToString ("F2") + "\nBest Time: " + PlayerPrefs.GetFloat ("bestTime");
	}
}

Check your script in the Unity Support section.

http://forum.unity3d.com/threads/243660-Help-With-Setting-High-Score-Float-C

You are having problems because you never set runTime and bestTime, it seems; PlayerPrefs.GetFloat() returns a float. Its second parameter is the default value. Also, do you ever need the runTime variable? I would put much of the logic in the OnDestroy() method;

void OnStart () {
    bestTime = PlayerPrefs.GetFloat( "bestTime", 0.0f ); // defaults to 0.0f
}

void OnDestroy () {
    // Is the time since this level was loaded higher than the current bestTime?
    // If it is, we have a new bestTime.
    if ( Time.timeSinceLevelLoad > bestTime ) {
        PlayerPrefs.SetFloat( "bestTime", bestTime );
    }
}