Command blocks let you run commands automatically when players walk near them or activate them

A command block is a special block in Minecraft that executes commands when activated. Unlike typing commands into the chat yourself, a command block runs the same command over and over or triggers it when a player steps on it, walks past it, or interacts with it. Command blocks only work in Creative mode or on servers where the owner has turned them on — they do not appear in Survival mode by default.

Command blocks are useful for building adventure maps, creating mini-games, or automating repetitive tasks. For example, you can set one to give every player who enters an area a specific item, or to teleport them to a different location. The block itself is invisible to players unless you specifically look for it, so you can hide the mechanics behind your build.

Key Takeaways

  • Command blocks only work in Creative mode or on servers with cheats turned on — you cannot use them in regular Survival mode.
  • You obtain a command block by typing a command in the chat, not by crafting or finding it in the creative inventory.
  • Every command block has three settings: the command itself, the type (Impulse, Chain, or Repeat), and the activation method (Always Active, Needs Redstone, or Conditional).
  • The most common setup is an Impulse block set to Needs Redstone, which runs the command once each time it receives a redstone signal.

Getting a command block in Creative mode

Open your world in Creative mode. If you are playing on a server, make sure the server owner has enabled command blocks in the server settings — if they have not, you will not be able to use them even in Creative mode.

Open the chat window by pressing T (on Windows) or the appropriate chat key for your platform. Type the following command exactly as shown:

/give @s command_block

Press Enter. A command block will appear in your inventory. You can now place it in the world like any other block. If the command does not work, double-check that you are in Creative mode and that cheats are turned on. On a server, ask the owner to confirm that command blocks are enabled.

Opening and configuring a command block

Place the command block in the world. Right-click on it (or use your interact key) to open the command block interface. You will see a text field where you can type a command, along with several dropdown menus below it.

Type the command you want to run in the text field. For example, give @s diamond 10 will give the nearest player 10 diamonds. The command must be valid Minecraft syntax — if it is wrong, the block will turn red and show an error message when you try to confirm it.

Below the text field, you will see three settings. The first dropdown is Command Block Type. Choose one of these:

  • Impulse: Runs the command once when activated. This is the most common choice.
  • Chain: Runs the command when the previous command block in a chain finishes. Used for sequences of commands.
  • Repeat: Runs the command every game tick (20 times per second) as long as it is activated. Use this carefully — it can lag your world.

The second dropdown is Activation Mode. Choose one of these:

  • Always Active: The block runs its command constantly (or once per tick for Impulse blocks). Do not use this unless you want the command running all the time.
  • Needs Redstone: The block only runs when it receives a redstone signal. This is the safest choice for most builds.
  • Conditional: The block only runs if the previous command block in a chain succeeded. Advanced option.

The third setting is Redstone Mode, which appears only if you chose "Needs Redstone". Leave this on the default unless you have a specific reason to change it.

Click "Done" to save your settings. The block will turn green if the command is valid, or red if there is an error.

Activating a command block with redstone

If you set your command block to "Needs Redstone", it will only run when it receives a redstone signal. The easiest way to test this is to place a redstone wire or a lever next to the block and activate it.

Place a lever on the side of the command block or on a nearby block. Pull the lever. The command block will run once (if it is set to Impulse) or repeatedly (if it is set to Repeat) while the lever is on. This is useful for testing — you can turn the lever on and off to see if your command works.

For a more permanent setup, you can use a pressure plate, a tripwire, a button, or any other redstone component. For example, a pressure plate in front of the command block will activate it whenever a player steps on it. A button will activate it once per press. This is how you create automated triggers for your builds.

Common command block commands and what they do

Here are some commands that work well in command blocks. Replace the parts in brackets with your own values:

  • /give @s [item] [amount] — Gives the nearest player a specific item. Example: /give @s diamond 5
  • /teleport @s [x] [y] [z] — Teleports the nearest player to specific coordinates. Example: /teleport @s 100 64 200
  • /say [message] — Broadcasts a message to all players in the chat.
  • /setblock [x] [y] [z] [block] — Places a block at specific coordinates. Example: /setblock 0 64 0 diamond_block
  • /kill @s — Kills the nearest player (useful for adventure maps with hazards).
  • /effect give @s [effect] [duration] — Gives the nearest player a status effect. Example: /effect give @s speed 60

For a full list of commands and their syntax, check the official Minecraft wiki or the in-game command help. Commands vary slightly between Java Edition and Bedrock Edition, so make sure you are using the right syntax for your version.

Troubleshooting command blocks that do not work

If your command block turns red or does not run, check these things first. Make sure the command syntax is correct — even a small typo will break it. Copy the command from the official wiki if you are not sure. Verify that you are using the right command for your Minecraft version (Java or Bedrock commands are different).

If the block is set to "Needs Redstone", make sure it is actually receiving a redstone signal. Place a redstone lamp next to it — the lamp will light up when the block receives power, so you can see if the signal is reaching it. If the lamp does not light, your redstone circuit is broken.

If you are on a server, confirm with the owner that command blocks are turned on in the server settings. Some servers disable them for security reasons. If they are disabled, you will not be able to use them no matter what you do.

If the command runs but does nothing, the target selector might be wrong. @s targets the nearest player, but if no player is nearby, nothing happens. Use @a to target all players, or @p to target the nearest player specifically.

Frequently Asked Questions

Can I use command blocks in Survival mode?

No. Command blocks only work in Creative mode or on servers where the owner has turned them on. In regular Survival mode, you cannot place or use them. If you want to use command blocks on a server, ask the server owner to enable them in the server settings.

What is the difference between Impulse and Repeat command blocks?

An Impulse block runs once each time it receives a redstone signal. A Repeat block runs every game tick (20 times per second) as long as it is activated. Use Impulse for single actions like giving items or teleporting. Use Repeat only if you need something to happen constantly, and be careful — it can cause lag.

How do I make a command block run when a player walks near it?

Place a pressure plate or tripwire in front of the command block and connect it with redstone wire. When a player steps on the pressure plate, it sends a redstone signal to the command block, which runs the command. You can also use a tripwire hook to detect when a player walks through a specific area.

Can I chain multiple command blocks together?

Yes. Set the first block to Impulse and the second to Chain. Point the Chain block at the back of the first block (the arrow on the block shows which direction it is facing). When the Impulse block runs, it will trigger the Chain block, which will trigger the next one, and so on. This lets you run a sequence of commands in order.

Why does my command block show an error message?

The command syntax is wrong. Check the spelling, make sure you are using the right command for your Minecraft version, and verify that all brackets and special characters are correct. Copy the command from the official wiki to avoid typos. If you are still stuck, try a simpler command first to make sure the block itself is working.