The object of type 'GameObject' has been destroyed but you are still trying to access it.

I wanna make an inventory system. When mouse down on item, add gameobject to inventory scripts item list. I make it all. But when item destroyed, gives this error:
The object of type ‘GameObject’ has been destroyed but you are still trying to access it. I know why giving this error. But i must do this. How to i can?

If you want to “store” the object in the inventory and remove it from the scene, don’t destroy the object: deactivate it instead with SetActive(false), and reactivate when needed with SetActive(true) - for instance:

inventory.Add(myObject); // add myObject to inventory list
myObject.SetActive(false); // "hide" it without destroying the object