How to make it so that when you open a door you enter the room you want to exit?

Hello everyone,

I have another question, and I will get straight to the point.

How can I make it so that if the player does not interact with an object (lets make it a key) and he wants to exit the room through interacting with the door, he enters the same room again. (Something PT made made you enter the same hall over again, I kind of want to reproduce that.)

How can I make the door part possible?
I am working in 3D mode if that is important to know.

Thank you all in advance,
Daniel Nowak Janssen

Something like…

void OnPlayerInteractsWithDoor(){
  if(playerHasKey)
    teleportLocation = locationOfNewRoom;
  else
    teleportLocation = locationOfCurrentRoom;

  player.transform.position = teleportLocation;
}

I always imagined they had several copies of the room connected to the door in P.T. and in code it would decide which room to load/enable (either the same one or a slightly different one) to make the transition seamless.