title: Unity variable of .. has not been assigned
body: <p>I am trying to make enemy fire at me. My script looks good but it says target variable has not been assigned. In inspector I selected my player object into target slot. But it keep saying the same error.</p>
  
  <pre><code>public GameObject AntagonisticElement;
  public GameObject Target;
  public float bulletSpeed;
  public float enemySpeed;
  public float bulletDestroyTime;
  public GameObject explsn;
  public GameObject bulletPrefab;
  public Transform bulletSpawn;
  
  Vector3 pos;
  
  public float min = 20;
  public float max = 10;
  
  // Use this for initialization
  void Start () {
      Target = GameObject.FindGameObjectWithTag("Tank");
  }    
  // Update is called once per frame
  void Update () {
  
      transform.LookAt(Target.transform.position);
  
      if (Vector3.Distance(AntagonisticElement.transform.position, Target.transform.position) &gt;= min)
      {
          AntagonisticElement.transform.position += AntagonisticElement.transform.forward * 4 * Time.deltaTime;
  
      }
      if (Vector3.Distance(AntagonisticElement.transform.position, Target.transform.position) &lt;= max)
      {
          shootAt();
      }
  
  }
  
  void shootAt()
  {
  
      Instantiate(explsn, bulletSpawn.position, bulletSpawn.transform.rotation);
      var bullet = Instantiate(bulletPrefab, bulletSpawn.position, bulletSpawn.rotation);
      bullet.GetComponent&lt;Rigidbody&gt;().velocity = bullet.transform.forward * bulletSpeed;
  
  }
  </code></pre>