How would I get the position of another object to spawn an object at

Hi guys, I have the following script which will spawn an object at the position of the object that this is placed on, but I’d like it to spawn at the location of a different object

Like in the following script I need to swap out

var TargetObject : GameObject

OnTriggerenter ()
{
//get the script for the position of anouther object 
        	var instance : GameObject = Instantiate(thePrefab, transform.position// right here I need the pos of a different object which will ultimately be a var  , transform.rotation);
}

All you need is reference the TargetObject position by using TargetObject.transform.position

Here’s a little example:

     var TargetObject : GameObject
     
   function OnTriggerenter ()
    {
    //get the script for the position of anouther object
                var instance : GameObject = Instantiate(thePrefab, TargetObject.transform.position , transform.rotation);
    }

Thanks, Its amazing how much everyone here is willing to help !

No problem, if you need any help the community is here! :wink: