key to open gate

hello all

can anyone help me im looking for a scrip that will allow me to be able to pick up a key and use it to open a gate. i need it to be like when you get next to the key it says "do you wish to pick up key" to pick it up you need to press E then with the key you go to the gate and open gate by pressing E, but if you don't already have the key when you press E next to the gate it will say "Gate locked"

if you can help me that will be awesome

I recommend you take a look at this book. It has many easy to follow tutorials that will lead you to setting up your key routine.

https://www.packtpub.com/unity-game-development-essentials/book