what I'm asking here will be something that I didn't knew how to solve since I use commands blocks. When I target a player, there is @p, @a, @e, and @r. But what I wanted was that the command block target the player that was, like, the nearest, and then continue to target this one until we say to stop.

What I wrote above is my question; if it requires to use the /scoreboard command, please tell me how to use it.


2 Answers 2


You must label the closest player first and then perform actions upon the player with that label.

For example, the following labels the closest living player:

/scoreboard players tag @p add closest

Or if you want to include dead players in selection, you must use @a:

/scoreboard players tag @a[c=1] add closest

Then you can target players with that tag:

/say @a[tag=closest]

And you would remove the tag when finished:

/scoreboard players tag @a[tag=closest] remove closest

I depends on what you are asking here. Are you wanting to tag the nearest player even when they are no longer the nearest player or just continue to tag the nearest player.

For the first one you would just need to run /scoreboard players tag @p add closest, just as Skylinerw suggested.

For the second option you would need to simply set up a clock system and run /say @a. That will continue to display the closest players name. You could also use /title @a title {text:"The nearest player is, ",color:white,extra:[{selector:"@p"}]}, which would display the nearest player's name as a title.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .