Minecraft – way to make something happen only to players with a certain value

minecraft-java-edition

I'm setting up a loop that turns players into a certain block, but I only want certain people to be changed. Can anyone help?

Best Answer

To select players with a certain scoreboard value, use the score_[SCORENAME]=[MAX] and score_[SCORENAME]_min=[MIN] arguments in your entity selector. For example, to select people with a TurnToBlock score of at least 1:

@a[score_TurnToBlock_min=1]

You can use this in a command:

/say @a[score_TurnToBlock_min=1]

If by "certain value" you don't mean score values, then the wiki has a full list of other arguments can select players by:

Argument(s)     Selection criteria
x, y, z         coordinate
r, rm           radius (max, min)
m               game mode
c               count
l, lm           experience level (max, min)
score_name      max score
score_name_min  min score
team            team name
name            entity name
dx, dy, dz      volume dimensions
rx, rxm         vertical rotation (max, min)
ry, rym         horizontal rotation (max, min)
type            entity type

You can use these in the same way as above. For example, to only select players in creative:

/say @a[m=1]