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 person with a writable_book with a message, and on a certain team - 2 Men in Red and White Jersey Shirt Sitting on Grass Field

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"

I want to have a testfor command that only teleports a person with a writable_book with a message, and on a certain team - High angle of excited young diverse friends in casual outfits with arms raised yelling happily while celebrating project success in modern workspace
I want to have a testfor command that only teleports a person with a writable_book with a message, and on a certain team - Happy diverse friends taking selfie in park
I want to have a testfor command that only teleports a person with a writable_book with a message, and on a certain team - Friends Having Fun Playing a Video Game



How do I use the Testfor player command?

How to Enter the Command
  • Test if Players are within 10 blocks. In this example, we will test to see if there are any players within a 10 block radius with the following command: /testfor @a[r=10] ...
  • Test if Mooshrooms are within 50 blocks. ...
  • Test if Nearest Player is at Level 20 experience.




  • Why 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