I want to have a command block with a button.
When clicking the button the command block should clear himself and spawn three new command blocks.
But here is the tricky part the new command blocks should have the name of the player who pressed the button.
Basically when the players name is Dinnerbone the new command blocks should have the command:

/tp @p[name=Dinnerbone] ~ ~1 ~-3

When the player who presses the button is named Notch the command of the new command blocks should be:

/tp @p[name=Notch] ~ ~1 ~-3

Is this even possible?

  • The closest you could get is by this command, i think: /say /tp @ p[name=@p] ~ ~1 ~-3 or something simmilar :D – RudolfJelin May 10 '16 at 13:13
  • 1
    Automatically placing the name of the player in a command block isn't possible, but you should be able to do what you want with scoreboard tags. – MBraedley May 10 '16 at 13:27

That's not possible right now (1.9.4).

What you can do, is give the player a tag: (Put this command block behind the button)

/scoreboard players tag @p add THEONE

Then (in repeating command block) put the command you want to execute:

/tp @a[tag=THEONE] ~ ~1 ~

Append your commands into Chain-command-blocks. Append a Chain-Command-block put this command:

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

To reset the machine.

The setup:

enter image description here

Hope it helped (:

  • This might actually help me. I have to infestigate the whole scoreboard thing a little bit more. – Eydamos May 10 '16 at 19:42
  • @Eydamos: The scoreboard is a very important tool in a command blocker's toolbox. It forms the basis of a lot of contraptions. It, along with execute are the two commands that you should really study and familiarize yourself with, because you'll use them a lot. They are the general purpose commands that are used to make everything else work. – MBraedley May 10 '16 at 21:02

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.