title: How to delete one gameObject with a tag in Unity?
body: <p>I have a map made of 6 blocks with a tag LevelBlock. After the car leaves the block it was currently on I want to delete that block. Now my code deletes random LevelBlock but not the one the car was previously on. How do I delete the LevelBlock that is no longer in use?</p>
  <p><a href="https://i.stack.imgur.com/fkybH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fkybH.png" alt="Screenshot of the map here" /></a></p>
  <p>Here's my code:</p>
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using UnityEngine.Diagnostics;
  
  public class TriggerExit : MonoBehaviour {
  
  public float delay = 5f;
  
  public delegate void ExitAction();
  public static event ExitAction OnChunkExited;
  
  private bool exited = false;
  
  private void OnTriggerExit(Collider other)
  {
      CarTag carTag = other.GetComponent&lt;CarTag&gt;();
      if (carTag != null)
      {
          if (!exited)
          {
             exited = true;
             OnChunkExited();
             StartCoroutine(WaitAndDestroy());
          }
      }
  }
      
  IEnumerator WaitAndDestroy()
  {
     
      yield return new WaitForSeconds(delay);
  
      // Destroy the LevelBlock
      var block = GameObject.FindWithTag(&quot;LevelBlock&quot;);
      Destroy(block);
  }
  </code></pre>
  <p>}</p>