How to kill name tag villagers with command blocks?

How to kill name tag villagers with command blocks? - White visiting card with empty space for data placed on light pink background

So I was planning to do my minecraft server and I want the command block to kill name tag villagers. I don't want my players to name "LeafyisHere", "drugs" and others.



Best Answer

Strictly speaking, this is fairly easy to do, however it does require one additional steps in a scoreboard tag command.

For each name you don't want, you'll want a repeating command block like so:

/scoreboard players tag @e[type=Villager] add tokill {CustomName:"Name"}

From there, you'll have one repeating command block for the kill command:

/kill @e[type=Villager,tag=tokill]

That said, since it sounds like you're trying to eliminate bad behavior with this sort of system, the better solution would be to attempt to find the culprits and ban them, rather than attempting to implement a sort of exhaustive filter. The name matches are literal matches, so you'd need one command block for every single possibility, which will not be practical in the long term.




Pictures about "How to kill name tag villagers with command blocks?"

How to kill name tag villagers with command blocks? - Wooden name tags arranged on table during wedding ceremony
How to kill name tag villagers with command blocks? - Herd of domestic cows cattle animals pasturing in grassy valley with wire fence in agricultural settlement
How to kill name tag villagers with command blocks? - Cows grazing in green field



How do you kill someone in Minecraft with a command block?

Examples
  • To kill the player executing the command: kill @s.
  • To kill the player Steve: kill Steve.
  • To kill item entities: kill @e[type=item]
  • To kill all entities within 10 blocks: ...
  • To kill all entities except players: kill @e[type=!player]
  • To kill all creepers within 10 blocks:


  • What is the command to kill all villagers?

    Kill Command In all Minecraft editions, the command for killing everything in the world is \u201c /kill <target> \u201d. Typing \u201c /kill \u201d any target in the console will destroy pretty much everything that can be removed, including the player.

    How do you change a name tag in Minecraft with command blocks?

    There is no command to change a player's name. As a workaround, you could fake it by hiding the player's name whilst teleporting a named entity onto them.

    How do you kill a specific villager in Minecraft?

    Villagers are attracted to pumpkins and doors, so put one down, then build a deep hole around it (as deep as you can). Then sit back and watch as the villagers fall to their doom! Kill the Iron Golem. Put a bunch of TNT around him and make it explode!



    3 Deadly Command Blocks (Minecraft PE)




    Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

    Images: Angela Roma, Arina Krasnikova, Tara Winstead, Helena Lopes