Why does execute "as" not work in Command Block

Why does execute "as" not work in Command Block - Cheerful black manager looking at smartphone while walking down street

Basically, I am trying to make a system so that when a player dies a dead body (armour stand with team colour) spawns 1 Block underneath the death spot so that when it is lying on the ground the legs are hidden.

I tried to use this command in my setup:

/execute as (player_placeholder) run tp @e[distance=..150,type=minecraft:armor_stand,name=Corpse] ~ ~-1 ~

but it only teleports my armour stand to the command block and not to my friend (player_placeholder).

Could someone tell me why or maybe find a different solution for my plan?



Best Answer

The as subcommand only changes the executing entity, but the position does not change, meaning the position will still be at the previous executing entity. You need to use at @s to move the position to the target entity. Like this:

execute
  as (selector)
  at @s
run
tp @e[distance=..150,type=minecraft:armor_stand,name=Corpse] ~ ~-1 ~



Pictures about "Why does execute "as" not work in Command Block"

Why does execute "as" not work in Command Block - From below of lots of long narrow identical windows of contemporary construction in sunlight
Why does execute "as" not work in Command Block - Crop mother and daughter sitting on bed while using laptop
Why does execute "as" not work in Command Block - Aerial Photo of Buildings



How do you execute a command block?

Steps to Use a Command Block
  • Place the Command Block in Creative Mode. Before you can program and use the command block, you need to place the command block on the ground. ...
  • Add a Redstone Device. Next, you need to add a redstone device next to the command block. ...
  • Program the Command Block. ...
  • Activate the Command Block.


  • How does conditional work in command blocks?

    "Conditional": A command block in conditional mode will only execute its command after the command block behind it has executed successfully. ("behind it" in the sense of opposite to the direction the command block is facing, regardless of chain direction or even if chaining is occurring).

    Can a command block execute multiple commands?

    To make your command block run multiple commands, you will need to summon FallingSand or falling_block (depending on your version of Minecraft) with command blocks and redstone blocks for each command. The command blocks will be stacked one on top of the other and contain the individual command.

    How do you use the Block command test?

    You can test whether there is a certain block at a specific location in the game using the /testforblock command in Minecraft....TestForBlock Command in Minecraft Java Edition (PC/Mac)
  • x y z is the coordinate to test. ...
  • block is name of the block to test for. ( ...
  • dataValue is optional. ...
  • dataTag is optional.




  • Why Command Block Tutorials NEVER Work For You - Minecraft




    Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

    Images: Ono Kosuki, Ave Calvar Martinez, Tatiana Syrikova, Jimmy Chan