Target specific player to teleport mob to, for my hide and seek map
I'm trying to disguise players as mobs. I need to make sure the mob teleports to only the hider.
@p
teleports to whoever is closer
@a
and @r
don't work either.
I have to give the player invisibility to disguise them and then tp the mob in a repeating command block with the command:
/tp @e[type=(mob)] (yourself or @p)
This is a great use for scoreboard tags. You can give the player a tag and then use this tag to target that player. The command to add a tag would be:
scoreboard players tag <entity> add <tagName>
Change <entity>
to the player name and <tagName>
to whatever name you like.
Then your repeat command uses the specified tag in the target selector. I also recommend adding the count selector argument to prevent more then one mob from teleporting:
tp @e[type=TYPE,c=1] @a[tag=TAG]
Replace TYPE
and TAG
.
To remove the tag from the player:
scoreboard players tag <entity> remove <tagName>
Example commands using 'Hider' as the tag name:
/scoreboard players tag IronAnvil add Hider
tp @e[type=cow,c=1] @a[tag=Hider]
/scoreboard players tag IronAnvil remove Hider