Doors that you can enter once, then need a key to get back through

I need a door that allows you to enter into a room then the door locks behind you and a pickup is required to open it again. Unfortunately i'm no good with scripting, could someone please help me out?

The best way is to cut it in pieces. first, make a door. Then, make it lock when already opened. Then, check if character has key when door is locked.

What scripting language are you using?