title: How can I display collected amount of coins without overflow (accessing another script) in Unity?
body: <p>I have two scripts. <strong>PlayerMove.cs</strong> and <strong>Spawner.cs</strong> .
  In PlayerMove.cs I want a function that changes the text to the number of coins.</p>
  
  <pre><code>void CountCoin()
  {
      cointext.text = ": "+ coincount;
      CountCoin();
  }
  </code></pre>
  
  <p>In Spawner.cs I spawn coins and I want to increase coincount(which is public variable of PlayerMove.cs) each time I spawn.</p>
  
  <pre><code>IEnumerator StartSpawningCoins ()
      {
          coin.GetComponent&lt;Renderer&gt;().enabled=true;
  
          yield return new WaitForSeconds(Random.Range(6f, 16f));
  
          GameObject k = Instantiate(coin);
  
          // my problem starts here
  
          GameObject Player = GameObject.Find("PlayerMove");
          PlayerMove playermove = Player.GetComponent&lt;PlayerMove&gt;();
          playermove.coincount++;
  
          //till here
  
          float x = Random.Range(min_X,max_X);
  
          k.transform.position = new Vector2(x, transform.position.y);
  
          StartCoroutine(StartSpawningCoins());
      }
  </code></pre>
  
  <p>When I use these I get stack overflow error. How can I fix it?</p>