title: Resetting Score on Restart
body: <p>I've got a small 2D game I'm creating with a score counter. On restart/game over I want the score counter to go back to 0 but I'm not sure how to go about that. This is for a game on Unity and I also call the counter on the player. I've attached my code down below and would appreciate any help! </p>
  
  <pre><code>public class CounterScript : MonoBehaviour
  {
      public int scoreValue = 0;
      Text score;
  
      void Start()
      {
          score = GetComponent&lt;Text&gt;();
          scoreValue = 0;
      }
  
      void Update()
      {
          score.text = "" + scoreValue;
      }
  }
  </code></pre>
  
  <p>Code on my restart button:</p>
  
  <pre><code>public class RestartButtonL1 : MonoBehaviour
  {
      public CounterScript counter;
  
      public void restartScene()
      {
          counter.scoreValue = 0;
          SceneManager.LoadScene("GameSceneA");
      }
  }
  </code></pre>
  
  <p>Code on my player:</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class Controller : MonoBehaviour
  {
      public float speed;
  
      private Rigidbody2D rb2d;
  
      public GameObject restartPanel;
  
      private CounterScript counter;
  
      private void Start()
      {
          counter = GetComponent&lt;CounterScript&gt;();
  
          restartPanel.SetActive(false);
  
          rb2d = GetComponent&lt;Rigidbody2D&gt;();
      }
  
      // ...    
  
      private void OnTriggerEnter2D(Collider2D other)
      {
          if (other.gameObject.CompareTag("PickUp"))
          {
              SoundManagerScript.PlaySound("sound");
  
              other.gameObject.SetActive(false);
  
              CounterScript.scoreValue += 1;
          }
  
          if (other.gameObject.CompareTag("Enemy"))
          {
              restartPanel.SetActive(true);
          }
      }
  </code></pre>