How can I pull an objects spawn vector

So I’ve created a spawn manager to load objects at random locations, and I’d like to pull that objects spawn location to essentially determine it’s path (Ping Pong across the scene essentially)

I can get this to work if I just have the object in the scene from the start rather than spawning it later, but I can’t seem to figure out how to pull it’s vector if I load it randomly into the scene.

How about doing this when spawning the object:

vector3 pos;
public void makeTheObject()//this is the void in which you instantiate the object
{
    GameObject object = Instantiate(prefab, new Vector3(2.0f, 0, 0), Quaternion.identity);

    pos = object.transform.position;
}

maybe I’m getting something wrong, but just try it anyway
(by the way, if anything is unclear, just ask :))

Yea didn’t really solve my problem but I think I’ve discovered why it’s not working - im identifying the object within the script by the name i’ve called it, and executing a command on that basis - but when it’s spawned the name changes, so it’s not running that bit of the script.

So instead change my script from saying if X == Y to if X.Contains Y