NapNodes

← Minecraft guides

Minecraft · updated 4 November 2026

Minecraft Target Selectors: @a, @p, @e, @s, @r and @n with Arguments and Examples

Almost every admin command asks who it affects: /give, /tp, /kill, /effect, /execute. Target selectors save you typing names one by one: @a is every player, @e every entity… and inside square brackets you filter them by type, distance, team or tag. Used well they save work; used badly, a /kill wipes out the whole server. Here's what each one picks and how to narrow it down.

The six selectors

This is Minecraft Java, the one servers with Paper run. Bedrock's selectors look similar, but several arguments have different names (distance, for example, uses r and rm).

  1. @a: all players

    Everyone online, including dead players who haven't respawned yet. /give @a bread 5 gives bread to the whole server.

  2. @p: the nearest player

    The player closest to where the command runs. In a command block, whoever is closest to the block; in chat, usually you.

  3. @r: a random player

    Any one of them, different each time: for giveaways (/give @r diamond 1) or to pick the “hunter” in a minigame.

  4. @e: all entities

    Mobs, animals, items dropped on the ground, arrows, boats, paintings, armor stands… and players too. That's why it almost always goes with a filter.

  5. @s: whoever runs the command

    You in chat, or the entity whose turn it is inside an execute as. From the console it's nobody.

  6. @n: the nearest entity

    Since 1.21: the closest entity, whatever its type. /tp @n[type=wolf] @s brings the nearest wolf to you.

Rather not set it up yourself? Minecraft servers from €6 a month, no contract and a full refund within 72 hours. Or create a free Minecraft server, no card needed.

Arguments: the filter in square brackets

After the selector, inside square brackets and separated by commas, go the conditions: @e[type=zombie,distance=..20] is every zombie 20 blocks away or less. No spaces between them. All of them have to be true at once.

Many can be negated with ! before the value: @e[type=!player] is everything except players, and @a[gamemode=!creative] everyone not in creative. Numbers are written as ranges: 5 is exactly 5, ..5 up to 5, 5.. 5 and up, and 2..5 from 2 to 5.

  1. type: which entity

    @e[type=cow], @e[type=item] (items on the ground), @e[type=!player]. Only on @e and @n: on @a, @p and @r the game rejects it because they're already players. You can negate several: @e[type=!player,type=!item_frame,type=!armor_stand]. The ids are the game's own, as in the target selector generator, which shows them with their in-game names.

  2. distance: how many blocks away

    Measured from where the command runs: @a[distance=..10] is every player 10 blocks away or less; @e[type=item,distance=30..], items dropped far away.

  3. x, y, z and dx, dy, dz: an area

    @a[x=100,y=60,z=-200,dx=20,dy=10,dz=20] is every player inside the box that starts at 100 60 -200 and measures 20 × 10 × 20. With x, y, z alone, you change the point distance is measured from. Handy for spawn areas or an arena.

  4. limit and sort: how many and in what order

    @e[type=zombie,sort=nearest,limit=3] is the 3 nearest zombies. sort accepts nearest, furthest, random and arbitrary. @p and @n already come with limit=1 and the nearest; @r, limit=1 at random.

  5. name: by name

    @e[name=Rex] is the entity with that name (a mob with a name tag, for example). If the name has spaces, use quotes: @e[name="Ana's Dog"].

  6. tag: by tag

    Tags are added with /tag @s add prize and filtered with @a[tag=prize] or @a[tag=!prize]. They're the cleanest way to mark who you've already given something to or who's in a minigame.

  7. team: by team

    @a[team=red], @a[team=!red] (everyone except red), @a[team=] (those with no team) and @a[team=!] (those with any team). How to create teams, in the /team guide (in Spanish).

  8. gamemode and level: players only

    @a[gamemode=survival], @a[level=30..] (experience level 30 or more). On @e, using either one leaves only players.

  9. scores: by score

    @a[scores={deaths=5..}] is every player with 5 or more deaths on the “deaths” objective. Several at once: scores={deaths=..2,kills=10..}.

  10. The less common ones

    x_rotation and y_rotation (where they're looking), advancements (@a[advancements={minecraft:story/mine_diamond=true}], whoever has already mined diamonds), predicate (a data pack's conditions) and nbt (by their internal data; it's slow and its format changes between versions, so a tag is better).

Examples you'll use on a server

  1. Clear items dropped on the ground

    /kill @e[type=item]. To keep the ones at spawn: /kill @e[type=item,distance=50..] from there. If you need it often because of lag, see the entity lag guide.

  2. Kill nearby hostile mobs without touching pets or players

    /kill @e[type=zombie,distance=..50], one type at a time. A bare /kill @e[distance=..50] also kills nearby players, dogs, villagers, paintings and armor stands.

  3. Bring everyone to spawn except creative players

    /tp @a[gamemode=!creative] 0 70 0.

  4. A one-time reward

    /give @a[tag=!welcome] bread 16 and then /tag @a add welcome. Anyone who already has the tag doesn't get it again.

  5. Make the red team glow for a minute

    /effect give @a[team=red] glowing 60. More effects in the /effect guide.

  6. Something on every player

    execute as @a at @s run …: as @a makes each player run the command (so @s is each of them) and at @s puts it where they are. It's explained in depth in the /execute guide.

Errors and what they mean

“No entity was found” or “No player was found”: the selector is written correctly but nobody matches the filter right now. Check the distance, the exact name (capitals included) or whether the mob is in unloaded chunks.

“Only one entity is allowed, but the provided selector allows more than one”: that slot in the command wants just one, like the destination of /tp. Add limit=1 or use @p, @n or @s: /tp @a @e[type=armor_stand,name=Spawn,limit=1].

“Only players may be affected by this command, but the provided selector includes entities”: it happens with /give @e …. Items can only be given to players: use @a, or @e with type=player.

“Option 'type' isn't applicable here”: you put type on @a, @p or @r. Remove it (they're already players) or switch to @e.

“Unknown option”, “Expected end of options” or “Expected value for option”: a misspelled argument, an unclosed bracket or an = with nothing after it. It happens a lot when there's a space after the comma.

“Min cannot be bigger than max”: the range is backwards, like distance=10..2. The small number goes first.

From the console, careful with @p, @s and distances

In the server console there's nobody behind the command: @s picks nobody, and distances and “the nearest” aren't measured from where you are but from the world spawn point. From there, better use the player's name or execute at YourName run …, which runs the command from where you stand.

On NapNodes

Minecraft servers run Paper on the latest version, so every selector in this guide works, @n included. Commands are typed in the panel's “Console”, without the slash; that's also where you op yourself with op YourName to use them from chat (more about op).

If you'd rather not write the selector by hand, the target selector generator builds it with a form, tells you in plain English who it picks and warns you if a /kill is going to take players with it. And if you don't have a server yet, the free one is enough to try them with your friends, no card needed.

Frequently asked questions

What do @a, @p, @r, @e and @s mean in Minecraft?

@a is every player, @p the nearest player, @r a random one, @e every entity (players included) and @s whoever runs the command. Since 1.21 there's also @n, the nearest entity.

How do I select only one type of mob?

With type: @e[type=zombie]. For everything except players, @e[type=!player].

How do I clear items on the ground with a command?

/kill @e[type=item]. That only removes dropped items, not mobs or players.

Why does /kill @e kill me too?

Because @e includes players. Use @e[type=!player] or, better, the exact type you want to remove.

How do I pick the players who are nearby?

With distance: @a[distance=..10] is everyone 10 blocks or less from where the command runs.

What do I do about the “Only one entity is allowed” error?

That command wants a single entity: add limit=1 to the selector or use @p, @n or @s.

Shall we set it up for you?

Minecraft servers from €6 a month, never oversold: your RAM is yours alone. And if you'd rather start without paying, there's a free Minecraft server, no card needed.

Your server doesn't show up in the game? Check it in a second with “Is my Minecraft server online?”: players, version and MOTD, free. Need a player's UUID for the whitelist or permissions? Look it up here. Handing out enchanted items? Build the command with the /give generator.

Free tool: Target selector generator. @a, @p, @e or @s with type, distance, name or tag: the selector written right, what it picks in plain English and a warning if it catches too much.

Keep reading

All Minecraft guides, sorted →