Next, You place a trapped chest, so they get a key from opening the trapped chest.
Attach redstone to the trapped chest with a command block. The first command block adds one more point to your new "checkkey" score, though only if you have zero. If you have one, then nothing happens.
Then make a second line of redstone connected to a command block that sends you a private message, telling you that you got a key, though only if your "checkkey" score is at 0, not higher or lower. You can also rename the command block in an anvil so it says in chat the name of your renamed command block Example : before "@ whispered to you, You got a bronze key!" After: "Bronze Key whispered to you, You got a bronze key!"
/tell @p[r=5,rm=1,score_checkkey=0,score_checkkey_min=0] You got a bronze key!
For this to work, set a repeater instead of redstone for the adding points to "checkkey" with the repeater set to take longer than the /tell command block.
Now, here is the part when you actually give the player the key part! It is very simple. Just make a command block that gives you one more point for your "bronzekey" score. Simply plug in a command block that gives you more points for your key score, and set it to only give you a point if you have no levels of the "checkkey" score. Or copy this in to a command block
You should now have a key system! Now here is how to make a teleporter/key door.
Making a teleporter/door that takes away your key:
First off, build your door, with a pressure plate. Attach a command block to it, which teleports you into a small one block wide hole, that the player can fit in. Set the command block to teleport the player into the hole, though only if they have at least one key or copy this into the block:
/tp @p[r=5,rm=1,score_bronzekey_min=1] [replace this with cords]
Then put a command block that removes that one key or copy this
and on the other side, put a command block that teleports them to the place past the door, or copy this:
/tp @p[r=5,rm=1] [replace this with cords]
Now test out your finished product!
Making a teleporter/door that just requires a key, though you keep the key afterwards:
Now this is easy! Simply make a teleporter/door that requires you to have at least one key. You could also make require more than one if you were making a mario 64 map, and you can also copy this:
/tp @p[score_bronzekey_min=1] [replace this with cords]
Notes: They do not have to be keys, you can make them the stars from mario 64, and you don't lose them when entering doors!
Notes: Please mention my name if you make a map with this tutorial.
Please enjoy this, and play around with this in a map!