Arqade Asked on August 27, 2021
Let’s say I want to target the nearest player to 5, 5, 5 and teleport them to 50, 50, 50:
/tp @p[x=5,y=5,z=5] 50 50 50
but then I want to /kill
them (specifically in this order). This would not work:
/kill @p[x=5,y=5,z=5]
because there may be another player there that is different.
How do I remember who I selected first to target them in multiple commands?
Tagging is a way to select specific players that have the tag. They can be added or removed at any time, and multiple players can have them. We do this via
/tag @p add MyTag
and remove via
/tag @p remove MyTag
We can select everyone with a tag with the selector @a[tag=MyTag]
.
First, instead of teleporting the player let's tag them:
/tag @p[x=5,y=5,z=5] add selected
We added a tag we call selected
to them. Now teleport them:
/tp @a[tag=selected] 50 50 50
Now kill them:
/kill @a[tag=selected]
Now take the tag away:
/tag @a[tag=selected] remove selected
Correct answer by Penguin on August 27, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP