Pick up and other

Hello everyone, i’m a beginner and i’m need help.
How to make a script
" I need closed door at start, but when u pickup the key, this door can be opened only by key. I mean, if u come to door before u found a key, on a display u can see the messege like a “Door Closed”, when u found key, by pressing button, again display messege “Key recieved”, and then when u come to the door and press some button, door opens and game is over. "

Have you actually tried? At least attempt the task and ask questions when you get stuck. If you go on google and do a quick search you will find alot of people have already asked and done this.

We are here to help if you get stuck, not to just write code for you.