I want to have a testfor command that only teleports a person with a writable_book with a message, and on a certain team
I want to have a testfor command that only teleports a player with a specific team and writable_book in their inventory, and in that book on the first page it reads: "Test".
I've tried dozens of commands but couldn't figure it out. Is this even possible?
Best Answer
What you are looking for looks something like this:
{Inventory:[{id:minecraft:written_book,tag:{pages:[0:"\"Test\""]}}]}
But the teleport command does not support NBT tags. However, there is a workaround using scoreboards.
First add a scoreboard objective:
/scoreboard objectives add HoldingBook dummy HoldingBook
Then run these 2 commands on a fast clock:
/scoreboard players set @a HoldingBook 2 {Inventory:[{id:minecraft:written_book,tag:{pages:[0:"\"Test\""]}}]}
/scoreboard players remove @a HoldingBook 1
Now, you can teleport the players holing a written book with the word "Test" on the first page, and for example on team blue;
/tp @a[score_holdingbook_min=1,team=blue] <your-coords>
Hope this helps.
Pictures about "I want to have a testfor command that only teleports a person with a writable_book with a message, and on a certain team"



How do I use the Testfor player command?
How to Enter the CommandWhy Sudo Is The Best Command in Minecraft
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Yogendra Singh, Matheus Bertelli, Andrea Piacquadio, RODNAE Productions
