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:
|@p||Targets the nearest player|
|@r||Targets a random player|
|@a||Targets all players|
|@e||Targets all entities (See list of entities in Minecraft)|
|@s||Targets the entity that is executing the command (referred to as “yourself”)|
Let’s explore what each of these target selectors do.
@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:
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.
Congratulations, you have learned about target selectors in Minecraft. Now, try a game command using a target selector.