I have a command block project I'm working on which has a bug in which armor stands keep spawning on the same block each time I run it.

But not just on one block, but many. So let's say there are 2,000 armor stands on a single block and 1,000 on another block. How do I kill all but one so I am left with 1 armor stand on one block and 1 on the other? Thanks!

P.S. If it would be helpful to know more about the project, I am working on implementing Conway's Game of Life in Minecraft. I will provide a world download if necessary.

1 Answer 1


I got this done in three commandblocks, and one scoreboard. Here are the commands:

/scoreboard players set @e[type=armor_stand] near 0
/execute @e[type=armor_stand] ~ ~ ~ /scoreboard players add @e[type=armor_stand,r=0,c=2] near 1
/kill @e[score_near_min=2,c=1]

command #1: this resets the scoreboard for the run

command #2: this adds one (to the scoreboard) to the armorstands that have another one in their square

command #3: and this kills one armorstand that has another armorstand in its square

Note: this set up kills one armorstand each time the three commandblocks are run, so it might be best to have it run on a clock. But aslong as you don't spawn the armorstands too quickly, you'll be fine

Note 2: The scoreboard I used is called near but you can use any name you'd like, as long as it matches in each block.

But I'd suggest you iron out the bug you have, rather then sticking something on to fix it.

EDIT: I got it to work so it kills all but one per group of armorstands, here's what I changed/added:

remove the kill command, and replace it with the following:

/scoreboard players tag @e[score_near_min=2,c=1] add nokill
/execute @e[tag=nokill] ~ ~ ~ /kill @e[r=0,tag=!nokill,type=armor_stand]
/scoreboard players tag @e[tag=nokill] remove nokill

Note: it kills all but one, per group of armorstands, so you have to run it once for each stack of armorstands.

EDIT2: I improved it some more, changes:

removed c=1 from:

/scoreboard players tag ... add nokill

and added

/kill @e[c=-1,tag=nokill]

just before:

/scoreboard players tag ... remove nokill

new command list:

/scoreboard players set @e[type=armor_stand] near 0
/execute @e[type=armor_stand] ~ ~ ~ /scoreboard players add @e[type=armor_stand,r=0,c=2] near 1
/scoreboard players tag @e[score_near_min=2] add nokill
/execute @e[tag=nokill] ~ ~ ~ /kill @e[r=0,tag=!nokill,type=armor_stand]
/kill @e[c=-1,tag=nokill]
/scoreboard players tag @e[tag=nokill] remove nokill
  • I agree, I will try to iron out the problem. But when you say, "You will have to put it on a clock." If it was on a repeating command block chain running continuously, would it remove all but one of the armor stands on a block?
    – R2bEEaton
    Apr 14, 2017 at 2:21
  • I found a way to make it so it has to be run once for each stack, much quicker than before
    – Venya
    Apr 14, 2017 at 2:43
  • I made it even faster now, now it can keep up with multiple repeating commandblocks, it's not perfect, it still takes a few runs to make sure each stack only has one
    – Venya
    Apr 27, 2017 at 2:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .