Maybe you could give the player a boolean instance variable?
Let's call it GotKey and set it to false
Player on collision with key
Player set boolean Gotkey to true
Key destroy
Player on collision with door
Player is boolean GotKey
Restart layout
So when the p[layer collides with the door, it will only restart the layout if the boolean GotKey is true..