You put that script on a little trigger volume (collider with 'isTrigger' set to true), and then link it to a door object in the inspector. Then, if something enters the trigger, it'll delete the door, and then itself.
OR to do Zelda style one-use-antimatter-keys-
On your player (somewhere in your player script)
Then, on your pickup a slight variant on the first one-
That gives you a key, and destroys the pickup.
Then on your door, something else similar (have a trigger volume along with an actual door- so that if the player enters the trigger with a key, the door opens)
That's a little more sophisticated!
If you wanted to check for specific keys, you could go even further and do something like this-
Then in your triggers for the pickups and the doors, use-
(Thanks, @wccrawford, for the suggestion!)
Then you'll need a few scripts.
When the player collides with the 'object', the script needs to set a variable (probably on the player) that says the player has the object.
When the player activates the door, the door's script needs to determine if the player has the object.