how to i make a door that can only be opened with a key/object?

how to i make a door that can only be opened with a key/object?

The basic logic is this:

  • variable to show that you have the key
  • try to unlock door
  • on unlock, check whether or not you have the key. If yes, open door. If not, don’t.

Now, for the nitty-gritty details. Are you using an inventory system? How are you picking up the key? The details of how it’s working will greatly influence how you build it.