Skip to content
[/craft]

Minecraft Target Selectors Explained (@p @a @e @s @r)

Target selectors are shorthand codes used in Minecraft commands to choose who or what the command affects. @p targets the nearest player, @a targets all players, @e targets all entities, @s targets the executing entity (yourself), and @r targets a random player. You can filter any selector further with arguments in square brackets, like @e[type=zombie,limit=1].

Updated 2026-07-03|Java 26.2 + Bedrock 26.32

What are target selectors?

Instead of typing a player's name every time, Minecraft commands use target selectors -- short codes starting with @ -- to dynamically choose targets at the moment the command runs. This lets one command affect different players depending on context, making selectors essential for multiplayer commands, command blocks, and automation.

All five selectors work on both Java and Bedrock Edition, though some selector arguments differ slightly between editions.

@p -- nearest player

@p selects the single player closest to where the command is executed. When you run a command in the chat, that is you. When a command block runs it, the nearest player to that command block is targeted.

Example:

/give @p diamond 64

Gives 64 diamonds to the nearest player. In singleplayer, @p always means you.

@a -- all players

@a selects every player currently in the world, regardless of where they are or what they are doing.

Example:

/effect give @a minecraft:night_vision 300 1

Gives Night Vision to every player on the server for 300 seconds. Useful for server-wide events or applying gamerule-like effects.

Note: @a only targets players, not other entities.

@e -- all entities

@e selects all entities in the world: players, mobs, dropped items, projectiles, boats, minecarts, armor stands, and more.

Example:

/kill @e[type=zombie]

Kills every zombie in the loaded world. Without arguments, /kill @e would kill everything including yourself -- always filter @e with a type argument.

Common @e uses: - Clear all dropped items: /kill @e[type=item] - Remove all arrows: /kill @e[type=arrow] - Target a specific mob near you: /kill @e[type=creeper,limit=1,sort=nearest]

@s -- the executing entity

@s refers to the entity running the command. In the chat, that is always you. In a command block, @s refers to the command block itself (useful in some contexts). In a function file or datapack, @s refers to the entity the function was invoked on.

Example:

/effect give @s minecraft:speed 60 2

Gives Speed II to yourself for 60 seconds. Using @s instead of @p is more precise -- @s always means the runner, while @p means the nearest player which could be someone else if running from a command block.

@r -- random player

@r selects one player at random from all currently online players. Useful for minigames, random rewards, or events.

Example:

/give @r minecraft:diamond 1

Gives one diamond to a randomly chosen player. Add a type argument to select a random entity of a specific type:

/kill @r[type=zombie]

Kills one random zombie in the loaded chunks.

Filtering selectors with arguments

Any selector can be narrowed with arguments in square brackets:

@e[type=zombie,limit=1,sort=nearest]

Common arguments:

type=<entity> -- filter by entity type (e.g. type=zombie, type=player) limit=<number> -- cap how many entities are selected sort=nearest or sort=random -- choose which matching entities are picked distance=<range> -- only select entities within a certain block distance (e.g. distance=..10 means within 10 blocks) name=<name> -- select a player or named entity by name team=<team> -- select members of a scoreboard team tag=<tag> -- select entities with a specific scoreboard tag nbt={...} -- Java Edition only: filter by NBT data

Frequently asked questions

What is the difference between @p and @s?

@p targets the nearest player to where the command runs. @s targets the entity running the command. In the chat they are the same (you are both the runner and the nearest player), but in a command block @p is the nearest player to the block while @s is the block itself.

Does @a include the player running the command?

Yes -- @a includes all players, including yourself. If you want to affect everyone except yourself, use @a[gamemode=!spectator] or combine with scoreboard tags to exclude specific players.

Can I use @e to target players?

Yes -- @e[type=player] selects all players, behaving like @a. However @a is simpler and preferred for player-only commands.

Do target selectors work on Bedrock Edition?

Yes -- @p, @a, @e, @s, and @r all work on Bedrock Edition. Some filtering arguments differ: Bedrock does not support NBT filtering via @e[nbt=...], and some argument syntax is slightly different.

How do I target a specific player by name?

Type the player's exact username directly in the command instead of a selector: /give PlayerName diamond 64. Alternatively, use @a[name=PlayerName] to select that player by name via a selector.

Commands to try