how to save the high score?

it prints hskor but i doesnt save it.
Do you see why?

function yuksek()
                                    {
                                       
                                        if (skor < hskor)
                                        {
                                            PlayerPrefs.SetFloat("high", skor);
                                            PlayerPrefs.Save();
                                            hskor= PlayerPrefs.GetFloat("high");
                                               
                                        }
                                       
                                    }

You can save high scores like this. I normally call this on the destroy function.

 if (Score> PlayerPrefs.GetInt ("High")) {

PlayerPrefs.SetInt ("High", Score);

Then after it is saved you can call and display the score for instance to a textmesh or something.

 public TextMesh HighScore;



        void Update ()
        {
       
          HighScore.text = "Best " + PlayerPrefs.GetInt ("High");   
       
        }

}
1 Like

thanks jewel,

i have got a variable for the hig score.
I will post it to the server.

Also I made a test project for this. And It worked just fine.
I dont know why did this not work in the game script?

hey jewel,
i did it in a very similar way like you did. thanks.

function Awake()
{
    if (PlayerPrefs.GetFloat("high") ==0 )
    {
        hskor=8.00;
    }
    else
    {
        hskor= PlayerPrefs.GetFloat("high");
    }
    Debug.Log ("rekor :: " +hskor );
   
}