Is there a way to use the "selector" command with tellraw so that it displays a players name in chat and THEN teleports that player to a location? I know how to do each separately but I don't know how to do both using the previously selected player who was chosen to be teleported. Please help.

  • It is in the chat or a command block? – Kimatuy Apr 28 '16 at 1:04
  • Why would you not want to do it separately? If you want both to be instantly after each other, just use a redstone stream. – deprilula28 May 13 '16 at 19:09

To clarify Daniel's answer, you can assign a tag to a player when they click on a command in the chat using the following command in a tellraw command:

/scoreboard players tag @p add command_clicked

Then, in a repeating command block chain, you can execute the following 3 commands in order:

/say @a[tag=command_clicked]
/tp @a[tag=command_clicked] <destination>
/scoreboard players tag @a remove command_clicked

One way to selector is like the example below:

/tellraw @a [{"selector":"@p","color":"dark_red"},{"text":" is now teleporting!","color":"red"}]

Then another one you could add if you want make execute /execute when they click:

/execute @a[tag=command_clicked] ~ ~ ~ /tellraw {command}

And another one doing:

/execute @a[tag=command_clicked] ~ ~ ~ /tp {command}

That might work, so like make tp a little bit more seconds tick like a redstone clock or maybe always active repeating and to make command blocks silent:

/gamerule commandBlockOutput false

It helps to make it silent to easily do a bunch; Deathrun is an example. You click something and teleport; that's one example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.