How do you pick up an instantiated object?

Hello! So I have the standard code to pick up an object within the scene:

public class PickUp : MonoBehaviour
{

    public Transform ObjectPos;

    void OnMouseDown()
    {
        GetComponent<Rigidbody>().useGravity = false;
        this.transform.position = ObjectPos.position;
        this.transform.parent = GameObject.Find("ObjectPosition").transform;
    }

    void OnMouseUp()
    {
        this.transform.parent = null;
        GetComponent<Rigidbody>().useGravity = true;
    }
}

My issue is that you can’t assign a transform to a prefab object because it hasn’t been spawned yet. I have a series of objects that spawn during Runtime that I need the player to be able to pick up. This seems like it should be super simple but I can’t find any information on it at all.

Reference the ObjectPos object from the class responsible for spawning the PickUp objects and inject the reference when instantiating the objects

 public class PickUpSpawner : MonoBehaviour
 {     
     public PickUp PickUpPrefab;
     public Transform ObjectPos;
 
     void SpawnPickUp()
     {
         PickUp pickUp = Instantiate(PickUpPrefab);
         pickUp.ObjectPos = ObjectPos;
     }
}