MiniBench

MiniBench / Learn

Explainer ~3 min read

Target selectors

Lots of commands ask "who?" — who gets the item, who gets teleported, who gets the effect. Target selectors are the shorthand that answers it, so you don't have to type player names.

@s

Self

The entity running the command — you, when you type in chat. The one you’ll use most in functions.

@p

Nearest player

The closest player to the command’s position.

@a

All players

Every player. Great for world-wide effects and messages.

@r

Random player

A random player — handy for minigames and raffles.

@e

All entities

Every entity, not just players. Almost always paired with a filter like type=.

Narrow it down with arguments

Add [ ] after a selector to filter it. A few common ones:

effect @a[r=8] regeneration 10 1

Give Regeneration II to every player within 8 blocks.

Rule of thumb

In a function you'll usually want @s (the runner), @a (everyone), or @e with a type= filter. Reach for arguments whenever "all of them" is too broad.

See selectors in commands.

They show up everywhere — start with give and effect.

The /give command