Skip to content
/SLASHPLAY

How to use the execute command in Minecraft

Type /execute as @a at @s run particle minecraft:heart ~ ~2 ~ in chat as an operator to run a command as, and at, every player.

execute

Runs another command with a changed executor, position, rotation or dimension, or only when conditions are met.

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

Examples

/execute as @a at @s run particle minecraft:heart ~ ~2 ~

Hearts above every player.

/execute if entity @a[gamemode=creative] run say Someone is in creative

Runs only if the condition holds.

/execute in minecraft:the_nether run tp Steve 0 100 0

Teleports Steve into the Nether.

Arguments

subcommandRequired
One or more of as, at, positioned, in, if, unless, store and others.
commandOptional
The command to run, without a slash.

What it does

Chain subcommands and end with run <command>. as changes who runs it, at moves to an entity's position, and positioned, rotated, facing, in, align, anchored, on and summon adjust the context. if and unless test blocks, entities, scores, data, predicates, items, biomes, dimensions, functions and loaded chunks, and store saves a result into a score, data or a boss bar.

Good to know

  • Needs operator permission level 2.
  • as changes who runs the command but not where; add at @s to also move the position.

Run it on your server

On a SLASHPLAY server, type it in the Console tab without the leading slash; in game, operators type it in chat with the slash. New to this? Start a Minecraft server first.

Your own
Minecraft server.

From $0.03 an hour, only while it runs. New accounts get 6 free tokens.