Minecraft executing on a random enitity not working

minecraft-commandsminecraft-java-edition

I am trying to set a stone block underneath a random armor stand, that is called disco stand. There are nine.

I put in this command:

/execute @r[name=DiscoStand] ~ ~ ~ /setblock ~ ~-1 ~ stone

… but it doesn't work. Any ideas, anyone?

Best Answer

@r, by default, only selects players. To get it to select another entity, use the type argument:

/execute @r[name=DiscoStand,type=ArmorStand] ~ ~ ~ /setblock ~ ~-1 ~ stone