In Minecraft, could I make a command block that has the /say command on my server with a command like the following:

/say <player> has entered this zone

to announce when a player enters the zone.

How can I have the player part changed to whoever clicked the button/activated the command block?

For example, If I click it it would say Justin has entered zone 1 but if my friend clicked it it would say Lukas has entered zone 1. I was just curious because it would help me as a server owner know where everyone is.

1 Answer 1


The /say command supports target selectors. Target selectors are used to target certain players for use in commands. In the /say command, entering a target selector will cause it to be replaced with the names of the players that it selects.

In this case, you'll want to use it to select the nearest player to the button. The @p target selector targets the nearest player. So, the command block activated by the button could have a command like this:

/say @p has entered zone 1

or a more complicated version for the experts:

/tellraw @a [{"selector":"@p"},{"text":" has entered zone 1"}]

You must log in to answer this question.

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