you should just need a global variable called open that starts at 0, and when a key is picked up assign it to 1 and when a door is opened assign it back to 0, this would allow you to have multiple keys and doors, to expand on this you could have different coloured doors with different keys but save that for the long run.