Skip to main content
Commands9 min read

Bedrock /execute Command: Advanced Command Running

Master the Bedrock Edition /execute command to run commands as other entities, at specific locations, and with conditional logic.

Overview

The /execute command is the most powerful command in Bedrock Edition. It lets you run other commands with modified context, meaning you can change who runs the command, where it runs, and under what conditions. This is essential for map making, minigames, and advanced command block systems.

Syntax

Bedrock Edition updated its /execute syntax to match Java Edition's modular approach. The command chains subcommands together:

/execute <subcommand> [subcommand...] run <command>

Common subcommands include: as, at, positioned, if, unless, in, anchored, and rotated.

Core Subcommands

as

Changes the executor of the command to the specified entities. The position does not change.

/execute as @a run say Hello
/execute as @e[type=zombie] run tp @s ~ ~1 ~

at

Changes the execution position to the location of the specified entities. The executor does not change.

/execute at @a run setblock ~ ~2 ~ glowstone
/execute at @e[type=villager] run particle minecraft:heart_particle ~ ~2 ~

as + at Combined

To run a command as an entity at that entity's location, use both:

/execute as @e[type=creeper] at @s run tp @s ~ ~0.5 ~

positioned

Changes the execution position to specific coordinates:

/execute positioned 0 64 0 run say I am at spawn
/execute positioned as @p run setblock ~ ~5 ~ torch

if / unless

Conditional execution. The command only runs if the condition is true (if) or false (unless):

/execute if block ~ ~-1 ~ diamond_block run say Standing on diamonds
/execute if entity @a[scores={deaths=1..}] run title @a title Death detected
/execute unless entity @e[type=zombie,r=50] run say Area is clear
/execute if score @s kills matches 10.. run give @s diamond 1

in

Changes the execution dimension:

/execute in nether run tp @s ~ ~ ~
/execute in the_end run setblock ~ ~1 ~ torch

rotated

Changes the execution rotation:

/execute rotated as @p run summon arrow ^ ^ ^2
/execute rotated 0 90 run tp @s ^ ^ ^5

Practical Examples

Kill Aura Detection

/execute as @a at @s if entity @e[type=zombie,r=3] run effect @s strength 5 0

For each player, if a zombie is within 3 blocks, give them Strength.

Mob Trail

/execute as @e[type=creeper] at @s run particle minecraft:basic_flame_particle ~ ~ ~

Creates fire particles at every creeper's position.

Safe Zone

/execute as @e[type=!player,family=monster] at @s if block ~ ~-1 ~ gold_block run kill @s

Kills any monster standing on gold blocks.

Conditional Rewards

/execute if score @p questProgress matches 10 run give @p diamond 5
/execute if score @p questProgress matches 10 run scoreboard players set @p questProgress 0

Chain Multiple Conditions

/execute as @a at @s if block ~ ~-1 ~ ice unless entity @s[hasitem={item=leather_boots}] run effect @s slowness 2 1

If a player stands on ice without leather boots, slow them down.

Differences from Java Edition

  • The subcommand structure is the same between editions, as Bedrock adopted Java's /execute syntax.
  • Bedrock supports hasitem as a target selector argument, which Java does not have.
  • Some condition checks available in Java (like checking block NBT) are not available in Bedrock.
  • Bedrock's /execute supports the if score subcommand for scoreboard comparisons.

Tips

  • Always test complex /execute chains in a creative world before deploying them.
  • Use as to change who, at to change where, and if/unless to control when.
  • Chain command blocks (green) are ideal for running follow-up commands after an execute check.
  • Be careful with @e selectors in execute chains, as they can create performance issues with many entities.

Related Astroworld Resources

Related Guides