why I am not getting highest value in my highscore textfield?

I am trying somethings like this…

using UnityEngine;
using System.Collections;

public class Score : MonoBehaviour {
	
	
	float highscore = 0.0f,score = 0.0f;
	OffSet2 OffSet; 
	
	void Start () {

		OffSet = GameObject.FindWithTag("MainCamera").GetComponent<OffSet2>();
		score = OffSet2.step;
		
		
		if(PlayerPrefs.GetFloat("highscore",0.0f) < score)
		{
				PlayerPrefs.SetFloat("highscore", score);
		}
	}
	
	void OnGUI()
	{
		GUI.Label(new Rect(300,210,70,20),"Score :");
		GUI.TextField(new Rect(400,210, 70, 20), score.ToString());
		GUI.Label(new Rect(300,240,80,20)," High Score :");
		GUI.TextField(new Rect(400,260, 80, 20), highscore.ToString());
	}
}

But I am getting zero value in my Highscore Textfield…

thanks!!
kajal

You are setting the value in PlayerPrefs but I cant see where you update the highscore variable of the script.

I guess that should fix it:

    if(PlayerPrefs.GetFloat("highscore",0.0f) < score)
    {
            PlayerPrefs.SetFloat("highscore", score);
            highscore = score;
    }

Still you are doing that in the Start so both values will be 0 and that won’t do much.

This should be called at some point later in the game for the values to be updated.