title: How to save high score?
body: <p>I am trying to save high score in my game. The high score is updated with the score during play. However, after level restarts, both (current score and high score) becomes zero.</p>
  
  <p>How can I do this? What mistake I am doing?</p>
  
  <p>Here is my code:</p>
  
  <p><strong>Generate</strong></p>
  
  <pre><code>public class Generate : MonoBehaviour 
  {    
      private static int score;
      public GameObject birds;
      private string Textscore;
      public GUIText TextObject;
      private int highScore = 0;
      private int newhighScore;
      private string highscorestring;
      public GUIText highstringgui;
  
      // Use this for initialization
      void Start()
      {
          PlayerPrefs.GetInt ("highscore", newhighScore);
          highscorestring= "High Score: " + newhighScore.ToString();
          highstringgui.text = (highscorestring);
          InvokeRepeating("CreateObstacle", 1f, 3f);
      }
  
      void Update()
      {
          score = Bird.playerScore; 
          Textscore = "Score: " + score.ToString();
          TextObject.text = (Textscore);
          if (score &gt; highScore) 
          {
              newhighScore=score;
              PlayerPrefs.SetInt ("highscore", newhighScore);
              highscorestring = "High Score: " + newhighScore.ToString ();
              highstringgui.text = (highscorestring);
          } 
          else 
          {
              PlayerPrefs.SetInt("highscore",highScore);
              highscorestring="High Score: " + highScore.ToString();
              highstringgui.text= (highscorestring);
          }
      }
  
      void CreateObstacle()
      {
          Instantiate(birds);
      }
  } 
  </code></pre>
  
  <p><strong>Bird</strong></p>
  
  <pre><code>public class Bird : MonoBehaviour {
      public GameObject deathparticales;
      public Vector2 velocity = new Vector2(-10, 0);
      public float range = 5;
      public static int playerScore = 0;
  
      // Use this for initialization
      void Start()
      {    
          rigidbody2D.velocity = velocity;
          transform.position = new Vector3(transform.position.x, transform.position.y - range * Random.value, transform.position.z);      
      }
  
      // Update is called once per frame
      void Update () { 
          Vector2 screenPosition = Camera.main.WorldToScreenPoint(transform.position);
          if (screenPosition.x &lt; -10)
          {
              Die();
          }
      }    
      // Die by collision
      void OnCollisionEnter2D(Collision2D death)
      {
              if(death.transform.tag == "Playercollision")
          {
              playerScore++;
              Destroy(gameObject);
              Instantiate(deathparticales,transform.position,Quaternion.identity);
          }
      }
  
      void Die()
      {
          playerScore =0;
          Application.LoadLevel(Application.loadedLevel);    
      }
  }
  </code></pre>