/tellraw with teleporting

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.



Best Answer

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



Pictures about "/tellraw with teleporting"

/tellraw with teleporting -
/tellraw with teleporting -
/tellraw with teleporting -



What is the command for teleporting?

Minecraft Tp Command ExamplesCommandEffect/tp @a @sTeleport all players to you./tp @p @sTeleport the nearest player to you./tp @e[type=pigs] @sTeleport all pigs to you./tp @s ~ ~100 ~Teleport yourself 100 blocks in the air.1 more row•Mar 26, 2022

What is the code for teleporting in Minecraft?

To teleport, tap the Chat icon once again, bring up the text box and type /tp YourUsername X Y Z, with X representing the east/west coordinate, Y representing the vertical coordinate and Z representing the north/south coordinate.

How does Tellraw herobrine join the game?

How to Enter the Command
  • Open the Chat Window. The easiest way to run a command in Minecraft is within the chat window.
  • Type the Command. In this example, we will send a private message to the player called DigMinecraft with the following command: /tellraw DigMinecraft {"text":"Herobrine joined the game","color":"yellow"}


  • How do you teleport to a player with a block?

    Type this command in when having the command block GUI open /teleport @p <x> <y> <z> . Then, activate the command block with redstone (including buttons, levers, and pressure plates), and they will be sent to their destination. The player can set up multiple different teleports.



    Chat Link Teleport System /tellraw command Minecraft




    More answers regarding /tellraw with teleporting

    Answer 2

    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.

    Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

    Images: