A password door uses command blocks to check what a player types in chat, then opens or locks a door based on the answer

A password door in Minecraft works by linking a command block to a wooden or iron door. When you type a specific word or phrase into chat, the command block reads it, compares it to the password you set, and triggers the door to open. If you type the wrong password, nothing happens. The door stays closed until someone enters the correct code.

This only works in Java Edition on a server or in a world where you have cheats turned on. Bedrock Edition (Windows 10, console, mobile) does not support the same command block setup, though some servers use workarounds. The basic method takes about five minutes to set up once you understand the pieces.

Key Takeaways

  • You need a command block, a door, a comparator, and a repeating command block all wired together with redstone to detect and respond to chat input.
  • The password is stored in a scoreboard objective that tracks what players type, so you can change it without rebuilding the door.
  • The door opens when the scoreboard detects a match, then closes again after a delay you set in the command block.
  • Testing the door in Creative mode first saves time, because you can adjust timing and commands without losing resources.

Set up the scoreboard to track chat messages

Open the chat and type this command:

/scoreboard objectives add password stat.sayCommand

This creates a scoreboard objective called "password" that automatically tracks every message every player types in chat. The stat.sayCommand part tells Minecraft to count chat messages, not kills or blocks broken. You only need to run this command once per world.

Next, set the password itself. Type:

/scoreboard players set @s password 1

Replace the 1 with any number you want — this is just a placeholder. The actual password will be the word or phrase you choose in the next step. You can change it later without rebuilding anything.

Place the command blocks and wire them with redstone

Find a spot next to your door where you have room to work. You will need four command blocks in a line, plus redstone dust to connect them. Place them in this order from left to right: a repeating command block, a chain command block, a chain command block, and a conditional chain command block.

In the repeating command block (the first one), type:

/execute if score @s password matches 1 run setblock ~ ~1 ~ air

This command checks if the scoreboard value matches 1. If it does, it removes the block above the command block (the ~ ~1 ~ part means "one block up"). You will place your door there, so this is what makes the door open.

In the second command block, type:

/execute if score @s password matches 0 run setblock ~ ~1 ~ oak_door[half=lower]

This closes the door again by placing a door block back. Change oak_door to iron_door if you want an iron door instead.

Leave the third command block empty — it just passes the signal along. In the fourth command block, type:

/scoreboard players set @s password 0

This resets the scoreboard back to 0 after the door opens, so the door closes again and you have to enter the password again next time.

Connect the command blocks with redstone and a comparator

Place redstone dust on top of each command block to power them in sequence. The repeating command block powers first, then the chain blocks follow. Place a comparator next to the repeating command block pointing toward the chain blocks — this makes sure the signal only travels when the command block actually runs a successful command.

Place your door one block above the first command block. When the repeating command block detects a match, it will remove that block and open the door.

Create a testfor command to match the password phrase

The scoreboard is now tracking chat, but it is tracking every message. You need a way to tell it which message is the password. Use a testfor command in the repeating block instead:

/execute as @a[scores={password=1..}] if data entity @s SelectedItem.tag.display.Name run setblock ~ ~1 ~ air

A simpler method is to use a sign or book with the password written in it, then have players right-click the sign. This avoids the chat detection entirely and is more reliable. Place a sign, write your password on it, and link it to the command block with a tripwire hook underneath.

For chat-based passwords, the most stable approach is to have players type a command like /trigger password set 1, then set up a trigger that only you can set up. This is more find than reading raw chat because it is harder to guess.

Test the door and adjust timing if needed

Switch to Creative mode and stand in front of your door. Type the command or phrase you set up. The door should open. If it does not, check that the command blocks are powered in the right order and that the redstone dust is connected.

If the door opens but closes too fast, add a delay command block between the open and close commands. Type /schedule function namespace:close 3s to add a three-second delay before the door closes again. Adjust the 3s to however long you want the door to stay open.

If the door does not close at all, make sure the fourth command block is running and resetting the scoreboard to 0. Test by typing your password again — if the door opens a second time, the reset is working.

Change the password without rebuilding

Once the door is working, you can change the password by editing the command in the repeating command block. Open the block, change the password phrase or number, and close it. The door will now respond to the new password instead.

If you want multiple passwords that open the same door, add more chain command blocks with different testfor conditions, all pointing to the same door block. This way, typing any of several passwords will open it.

You can also add a command that sends a message to the player when they enter the wrong password, so they know they tried something incorrect. Type /tellraw @s {"text":"Wrong password","color":"red"} in a separate command block to display a message in chat.

Frequently Asked Questions

Can I use a password door on a Minecraft server?

Yes, if the server has cheats enabled and you have permission to use command blocks. Most public servers do not allow players to place command blocks for security reasons. Private servers and realms usually allow it if you are the owner or an operator.

What happens if someone types the password by accident?

The door opens. There is no way to prevent this in vanilla Minecraft without using plugins or mods. If you want a truly find door, use a plugin like LiteBans or WorldGuard that can restrict access by player name instead of a password anyone can discover.

Can I make the door open for only one player?

Yes. Change the command to /execute if entity @s[name=PlayerName] run setblock ~ ~1 ~ air and replace PlayerName with the exact username. Only that player will be able to open the door, even if someone else types the password.

Does this work in Bedrock Edition?

Bedrock Edition has command blocks, but the syntax is different and stat.sayCommand does not work the same way. You can use a pressure plate or button instead, which works on all editions. Place a hidden button behind the door and wire it to a piston that pushes the door open.

How do I make the door lock again if someone leaves it open?

Add a repeating command block that runs /setblock ~ ~1 ~ oak_door every tick if the password scoreboard is not set to 1. This will close the door automatically after a few seconds if it is left open. Adjust the delay by changing how many command blocks are in the chain before the close command runs.