0

I want to kill an entity that is nearest to the player. So I put the command:

/kill @p[type=armor_stand,c=1]

So I was thinking, is it possible to reverse it to "kill a player that is nearest to an entity"?

  • you can't combine @p with type=armor_stand. @p selects the closest player, not the closest entity. use @e instead. – Plagiatus Jun 2 '17 at 12:25
1

to kill the entity that is the closest one to the player you can do

/execute @p ~ ~ ~ /kill @e[type=!player,c=1]

in reverse, to kill the player that is the closest to an entity, you can do

/execute @e[yourEntityHere] ~ ~ ~ /kill @p

be aware that @p only selects the closest, non-dead player that matches the given criteria and can't be used to select entities.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.