How can I kill only one item frame instead of all of them?

I tried using /kill @e[type=item_frame]. However, it kills every item frame. So my question is, how can I kill only one item frame?


You can add a scoreboard tag to the item frame when you spawn it in, so your kill function looks like this:

kill @e[type=item_frame,tag=killable]

with killable being the tag. If a player is running the command/you aren't spawning it in you can kill one within a certain radius:

kill @e[type=item_frame,distance=..1]

which will kill any item frames within one block.

Edit: I saw your other question and here's the summon command you would use:

summon minecraft:item_frame -1242 58 219 {Facing:2,Tags["killable"]}

Edit 2: I just remembered that a tag is not unique: if you have multiple entities tagged as 'killable' it will kill all of them. Instead, use a customName:

summon minecraft:item_frame -1242 58 219 {Facing:2,CustomName:"killableFrame"}

kill @e[name=killableFrame]