Target Selectors in Minecraft (2024)

This Minecraft tutorial explains all about target selectors and how to use them in game commands and cheats.

What is a Target Selector?

A target selector is used to target players or entities in your game commands. There are 5 target selectors that you can choose from:

Target SelectorDescription
@pTargets the nearest player
@rTargets a random player
@aTargets all players
@eTargets all entities (See list of entities in Minecraft)
@sTargets the entity that is executing the command (referred to as "yourself")

Let's explore what each of these target selectors do.

Target Selectors

@p (Nearest Player)

The @p target selector is used to target the nearest player in the game. The nearest player will always be the player closest to the location where the command is run.

If a command block has executed the command, the nearest player to the command block will be targeted. If you run a command from the Chat window, the player running the command will be the nearest player.

For example, you can use the @p selector with the /give command to give the nearest player 5 gold blocks:

/give @p gold_block 5

@r (Random Player)

The @r target selector is used to target a random player in the game.

For example, you can use the @r selector with the /give command to give a random player 15 emeralds:

/give @r emerald 15

@a (All Players)

The @a target selector is used to target all players in the game.

For example, you can use the @a selector with the /give command to give all players 2 emeralds:

/give @a emerald 2

@e (All Entities)

The @e target selector is used to target all entities in the game. This includes both players and mobs in the world.

For example, you can use the @e selector with the /kill command to kill all enderman:

/kill @e[type=enderman]

Notice that in this last example, we have used [type=enderman] to target only enderman. This value is called a target selector argument and allows us to filter the target.

Let's explore target selector arguments further.

@s (Entity executing the command)

The @s target selector is used to target the entity that is executing the command. This is often referred to as "yourself" in the Minecraft help.

For example, you can use the @s selector with the /give command to give the player who is running the command 64 tnt:

/give @s tnt 64

Target Selector Arguments

Target selector arguments can be used to reduce the number of players or entities being targeted and the available options are different between Java Edition and Bedrock Edition.

  • Java
  • Bedrock

Java Edition: Target Selector Arguments

In Java Edition, here are some of the more popular target selector arguments that you can use:

Target Selector
Argument
Description
advancementsAdvancement earned by entity.
distanceDistance to entity.
dxEntities between x and x + dx.
dyEntities between y and y + dy.
dzEntities between z and z + dz.
gamemodePlayers with gamemode. It can be one of the following values:
adventure, creative, spectator, survival, !adventure, !creative, !spectator, !survival
levelExperience level. It must be an integer value that is 0 or greater.
limitMaximum number of entities to target. It must be an integer value that is 1 or greater.
nameEntity name.
nbtNBT tag.
scoresScore.
sortSort the entities. It must be one of the following values:
arbitrary, furthest, nearest, random
tagScoreboard tag.
teamEntities on team.
typeEntity type (target must be the specified entity type - see list of entity values).
xEntity's x-coordinate position.
yEntity's y-coordinate position.
zEntity's z-coordinate position.
x_rotationEntity's x rotation (vertical rotation).
y_rotationEntity's y rotation (horizontal rotation).

A target selector argument is case-sensitive and always surrounded in [ ] such as [type=cow]. If there is more than one target selector argument used in a command, the arguments are separated by a comma such as [type=cow,limit=5].

Java Edition: Target Selector Argument Examples

Here are some examples of how to use target selector arguments in Java Edition.

To kill all cows:

/kill @e[type=cow]

To kill 5 cows:

/kill @e[type=cow,limit=5]

To give the 3 nearest players 64 emeralds:

/give @a[sort=nearest,limit=3] emerald 64

Java Edition: Common Mistakes with Target Selector Arguments

Here are some common mistakes made with dealing with target selector arguments in Java Edition.

1. Spaces between Target Selector and Argument

Do not put spaces between the target selector and the target selector arguments. If you do, the target selector argument will be ignored.

INCORRECT:

@e [type=cow]

CORRECT:

@e[type=cow]

2. Capitalizing the first letter of an Argument

Target selectors are case-sensitive and are generally all lowercase. Do not capitalize the first letter of an argument. If you misspell a target selector argument (and accidentally uppercase the first letter of the argument), the target selector argument will be ignored.

INCORRECT:

@e[Type=cow]

CORRECT:

@e[type=cow]

Bedrock Edition: Target Selector Arguments

In Bedrock Edition, here are some of the more popular target selector arguments that you can use:

Target Selector
Argument
Description
cCount (number of targets to select)
dxEntities between x and x + dx
dyEntities between y and y + dy
dzEntities between z and z + dz
lMaximum experience level
lmMinimum experience level
mGame mode (target must be playing in the specified game mode)
nameEntity name
rMaximum radius (target must be within the specified number of blocks)
rmMinimum radius (target must be more that the specified number of blocks away)
rxMaximum vertical rotation
rxmMinimum vertical rotation
ryMaximum horizontal rotation
rymMinimum horizontal rotation
tagScoreboard tag
typeEntity type (target must be the specified entity type - see list of entity values)
xEntity's x-coordinate position
yEntity's y-coordinate position
zEntity's z-coordinate position

A target selector argument is case-sensitive and always surrounded in [ ] such as [type=cow]. If there is more than one target selector argument used in a command, the arguments are separated by a comma such as [type=cow,r=50].

Bedrock Edition: Target Selector Argument Examples

Here are some examples of how to use target selector arguments in Bedrock Edition.

To kill all cows:

/kill @e[type=cow]

To give all players within a 50 block radius 6 emeralds:

/give @a[r=50] emerald 6 0

To give the 3 closest players 17 diamonds:

/give @p[c=3] diamond 17 0

Congratulations, you have learned about target selectors in Minecraft. Now, try a game command using a target selector.

Target Selectors in Minecraft (2024)

References

Top Articles
Latest Posts
Article information

Author: Arline Emard IV

Last Updated:

Views: 6079

Rating: 4.1 / 5 (72 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Arline Emard IV

Birthday: 1996-07-10

Address: 8912 Hintz Shore, West Louie, AZ 69363-0747

Phone: +13454700762376

Job: Administration Technician

Hobby: Paintball, Horseback riding, Cycling, Running, Macrame, Playing musical instruments, Soapmaking

Introduction: My name is Arline Emard IV, I am a cheerful, gorgeous, colorful, joyous, excited, super, inquisitive person who loves writing and wants to share my knowledge and understanding with you.