FindGameObjectWithTag return the first GameObject that is tagged with the tag. FindGameObjectsWithTag does not return one GameObject since it returns all GameObjects with that tag. The function returns an array of GameObjects. You can’t get one transform from multiple objects.
I’m not sure what you actually want, but maybe something like this:
var enemies : GameObject[]; // now an array of gameobjects
var distance = 0.5;
var life = 100;
function Awake()
{
enemies = GameObject.FindGameObjectsWithTag("Enemies");
}
function Update ()
{
for (var enemy : GameObject in enemies)
{
if(enemy != null && Vector3.Distance(transform.position, enemy.transform.position) < distance)
{
life -= 25;
if(life <= 0) // always check a range if possible
{
Destroy(gameObject);
}
}
}
}