Getting the transform.Postion off a instantiated object

I am making a basic RTS game and i have an enemy in the world that must be able to detect the players units.
The player units are instantiated objects that are in a List of gameobjects

public List<GameObject> pooledObjects;

pooledObjects = new List<GameObject>();
        GameObject tmp;
      

        for (int i = 0; i < amountToPool; i++)
        {
            if (pooledObjects.Count <= maxAllies)
            {
                tmp = Instantiate(objectToPool);
                tmp.SetActive(true);
                pooledObjects.Add(tmp);
            }
        }

Currently how i am detecting the player is:

 void PlayerDetection()
    {
        if(Vector3.Distance(gameObject.transform.position, playerScript.agent.transform.position) < 13f)
        {
                enemy.destination = GameObject.FindGameObjectWithTag("Player").transform.position;

        }
        else if (Vector3.Distance(gameObject.transform.position, playerScript.agent.transform.position) > 13f)
        {
            enemy.destination = gameObject.transform.position;
        }
    }

But doesnt work with the instatiated objects.

void AllyDetection()
    {
        if(Vector3.Distance(gameObject.transform.position, ally.transform.position) < 13f)
        {
            enemy.destination = ally.transform.position;
        }
        else if (Vector3.Distance(gameObject.transform.position, ally.transform.position) > 13f)
        {
            enemy.destination = gameObject.transform.position;
        }
    }

Finding ally with:

ally = GameObject.FindGameObjectWithTag("ally").GetComponent<GameObject>();

Have you tried instantiating “tmp” as a gameobject? Looks something like:

tmp = instantiate(ObjectToPool) as GameObject;

then you should be able to reference the GameObject’s transform.position by using tmp.transform.position.