title: when instantiated gameobject is destroyed it does not produce anymore clones
body: <p>I am making a 2D game where a ball keeps instantiating with a color red, green, blue or yellow. There is a square paddle with all the 4 colors. if the ball hits the same color it should destroy itself. I have made a script for instantiating the object. </p>
  
  <p>This is that script:</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class ballSpawn : MonoBehaviour {
  
      public GameObject ball;
      public Transform ballSpawnTransform;
      private float startTime = 2f; 
      private float repeatRate = 2f;
  
      // Use this for initialization
      void Start () {
          InvokeRepeating ("BallSpawn", startTime, repeatRate);
      }
  
      // Update is called once per frame
      void Update () {
  
      }
  
      public void BallSpawn(){
          ball = Instantiate (ball, ballSpawnTransform.position, ballSpawnTransform.rotation);
      }
  }
  </code></pre>
  
  <p>I have attached the color change method and destroy method with the prefab. the script for that is provided below:- </p>
  
  <pre><code>public class ball_controller : MonoBehaviour {
  
      [SerializeField]
      public int colorInt;
      Rigidbody2D rb;
  
      // Use this for initialization
      void Start () {
          //rb = this.gameObject;
          colorInt = Random.Range (1, 5);
          switch (colorInt) {
          case 1:
              gameObject.GetComponent&lt;Renderer&gt; ().material.color = Color.red;
              break;
          case 2:
              gameObject.GetComponent&lt;Renderer&gt; ().material.color = Color.green;
              break;
          case 3:
              gameObject.GetComponent&lt;Renderer&gt; ().material.color = Color.blue;
              break;
          case 4:
              gameObject.GetComponent&lt;Renderer&gt; ().material.color = Color.yellow;
              break;
          }
          rb = this.gameObject.GetComponent&lt;Rigidbody2D&gt; ();
          rb.velocity = new Vector3 (0f, -5f, 0f);
      }
  
      // Update is called once per frame
      void Update () {
  
      }
  
      void OnTriggerEnter2D(Collider2D hit){
          if (hit.gameObject.GetComponent&lt;Renderer&gt; ().material.color == gameObject.GetComponent&lt;Renderer&gt; ().material.color) {
              Destroy (this.gameObject);
          } else {
              DestroyObject (this.gameObject);
          }
  
      }
  }
  </code></pre>
  
  <p>but when it destroys the game object. It gives the following error .</p>
  
  <blockquote>
    <p>"MissingReferenceException: The object of type 'GameObject' has been
    destroyed but you are still trying to access it. Your script should
    either check if it is null or you should not destroy the object."</p>
  </blockquote>
  
  <p>It does not instantiate anymore balls and keeps giving this error for every ball it should have initiated. I want my script to keep instantiating clones. </p>