Minecraft – TP entity to other armorstand You must specify which player you wish to perform this action on

minecraft-commandsminecraft-java-edition

I'm trying to make a cutscene type thing where a zombie (prison guard) talks to you, then turns round and walks down a path. I know how to do the walking thing, but the turning is more difficult. I've spawned an invisible armor stand (LogPrisonGuard1) at the dimensions I want him to turn to, and I'm doing /minecraft:tp @e[name="Prison Guard"] @e[type=ArmorStand,name=LogPrisonGuard1]. When it activates however, I get this error:
You must specify which player you wish to perform this action on.
Any help?

Best Answer

The problem is with the @e[name="Prison Guard"] selector; you cannot use spaces in selectors, nor can you put quotation marks around strings in selectors.

I believe the error you are getting is caused by Minecraft understanding the command as having 3 arguments, which matches the /tp overload that can be used in chat but not in command blocks:

Command : /minecraft:tp
<x> : @e[name=Prison
<y> : Guard"]
<z> : @e[type=ArmorStand,name=LogPrisonGuard1]


Some potential solutions are to:

  1. Select the guard based on something else (e.g: position, tags, team)
  2. Give the guard a name without spaces (Warden, perhaps?)
  3. Use their CustomName NBT to first give them a tag, then select them from that tag.

For the third option, you'll need to run a command like this to add the tag:

/scoreboard players tag @e add IsPrisonGuard {CustomName:"Prison Guard"}

Then select them using: @e[tag=IsPrisonGuard]. This works because you can have spaces within quotations for NBT data, just not for selectors.