Nuke issue!

I have a nuke Button, and what I want to happen is when I press this beautiful button, I want the enemies to all die (which it works), but I have an FX that I want to spawn at these enemy positions when they die.

I have the following script which I am stuck on…

void OnMouseDown () 
	{
	gameObjects = GameObject.FindGameObjectsWithTag("Enemy");
		for(var i = 0 ; i < gameObjects.Length ; i ++)
		{
	GameObject Enemy = GameObject.Find ("Enemy");
	Transform EnemyTransform = Enemy.transform;
	Vector3 position = Instantiate (explosion, EnemyTransform.position,EnemyTransform.rotation) as Transform;
			Destroy(gameObjects*);*
  •  }*
    

}
}

Currently I get a The “as' operator cannot be used with a non-nullable value type UnityEngine.Vector3’” error

You don’t say what goes wrong with your current code so i can’t tell what to fix. But i see a couple of issues.

You already searched for all gameObject with tag Enemy, so you shouldn’t have to use Find in the loop. Also I don’t know if you can cast a Taransform to a Vector3.

         gameObjects = GameObject.FindGameObjectsWithTag("Enemy");
         for(var i = 0 ; i < gameObjects.Length ; i ++)
         {
     GameObject Enemy = gameObjects*;*

Transform EnemyTransform = Enemy.transform;
Transform position = Instantiate (explosion, EnemyTransform.position,EnemyTransform.rotation) as Transform;
Destroy(Enemy);

}