Missing Reference Exception: Box destoyed but crashes because still trying access it

Hello, I have a simple platform game consisting of a player which picks up a box. While the player walks to another object I programmed it so that the box will be destroyed upon collision with the other object. It works successfully, However, causes the following error and a game crash: “MissingReferenceException: The object of the BoxCollider2D has been destroyed but you are still trying to access it…”

Here is the code which deals with the picking up of the box.

 if (grabbed && holdpoint != null)
        {
            hit.collider.gameObject.transform.position = holdpoint.position;
        }
        else
        {
        }

As you can see, I have tried to use the parameters “Holdpoint != null” to tell the script that “if the box has been grabbed (picked up) ‘and’ the object (holdpoint) is no longer existent then it should keep holding the box in position.”

Any help would be useful thanks.

Also here is the code for the box collider of the other object if it helps

   void OnTriggerEnter2D(Collider2D target)
    {
        if (target.tag == "grabbable")
        {
         
            {
                Destroy(target.gameObject);
            }
        }
    }

You need to add what is commonly referred to as a ‘nullcheck’ - an if statement that basically says:

if (target.gameObject != null)
{
    Destroy(target.gameObject)
}