How can I kill all entities of a specific type, EXCEPT the youngest one?

//ads -- adsterra.com -- native banner
?>
I want to create armor stands whenever I stand on a certain block, but when I stand on it, it summons a lot of armor stands.
I tried /kill @e[type=ArmorStand,c=!1]
to kill all except the newest one but it killed all of them.
What should I do to remove all except the youngest?
Best Answer
Make a scoreboard
/scoreboard objectives add age dummy age
put a commandblock by a fill clock and type in
/execute @e[score_age=0,type=ArmorStand] ~ ~ ~ /scoreboard players add @e[type=ArmorStand] age 1
put another commandblock by a fill clock and type in
/kill @e[type=ArmorStand,score_age=2]
Pictures about "How can I kill all entities of a specific type, EXCEPT the youngest one?"



How do you delete specific entities in Minecraft?
ExamplesIs there a command to kill all hostile mobs?
Minecraft @ command specifies the entity. If you are trying to kill every mobs in different Minecraft Biomes except yourself, type the command /kill @e[type=! player].Kill Command Explained
More answers regarding how can I kill all entities of a specific type, EXCEPT the youngest one?
Answer 2
Just kill all the armorstands before you summon a new one
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Erik Mclean, Matheus Bertelli, Ylanite Koppens, Ylanite Koppens