title: Create array of gameobjects and destroy an object if .length == 0
body: <p>I am making a game that's similar to Bindig Of Isaac and I have the same door system. I want the doors to open when the number of enemies in the scene == 0. I created this code but I always get an error that says <code>NullReferenceException: Object reference not set to an instance of an object</code> I have no idea why this is not working. Any advice?</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class DoorOpen : MonoBehaviour {
  
  GameObject[] enemies = (GameObject[])GameObject.FindGameObjectsWithTag("Enemy01");
  
      void Update () {
  
          if (enemies.Length == 0) {
              Destroy (this.gameObject);
          }
  
  
      }
  }
  </code></pre>