How do i put potion effects on my sword? like in factions when you hit a player they get wither, poision, slowness, weakness, blindness, etc. ive looked on the internet for commands. i also tried to put factions on my multiplayer server and failed

  • How good are you at commands? I would like to know how detailed my answer should be to you. (I'd try to make a detailed one anyway but I don't have time) Jan 12, 2019 at 1:32
  • not really good. commands confuse me sometimes
    – WolfGod303
    Jan 12, 2019 at 1:38

1 Answer 1


The way I know how to do this is to track who gave damage and is holding a poison sword, then execute that target and give poison to the nearest player who has taken damage.

To track who has given or taken damage, use the following scoreboard:

/scoreboard objectives add dealt minecraft.custom:minecraft.damage_dealt
/scoreboard objectives add taken minecraft.custom:minecraft.damage_taken

These scoreboards accumulate player scores for damage they give and take.

Then place these command blocks in a repeating chain:

execute as @a[scores={dealt=1..},nbt={SelectedItem:{id:"minecraft:diamond_sword",tag:{display:{Name:"\"Poison Sword\""}}}}] at @s run effect give @a[scores={taken=1..},limit=1,sort=nearest] poison

This lets players who have given damage and is holding a diamond "Poison Sword" to give poison to the nearest player who has taken damage.

scoreboard players reset @a taken
scoreboard players reset @a dealt

These two commands refresh the scoreboards so the machine can run again later.

Name a diamond sword "Poison Sword" and try it out. If you don't want the name to be specified, replace the first command with:

execute as @a[scores={dealt=1..},nbt={SelectedItem:{id:"minecraft:diamond_sword"}}] at @s run effect give @a[scores={taken=1..},limit=1,sort=nearest] poison

(NOTE: There might be a more efficient method than this out there, but I never had the need to learn such a method so I'm sure this will do well for now.)

  • Nitpick: If you stand closer to one player, but hit another, while also someone hits the person closer to you in the same game tick, then the person closer to you gets the effect. :P Jan 12, 2019 at 12:53
  • Like I said, this isn't the most effective method I'm sure. I guess someone could do positioned ^ ^ ^2 to make it a bit more accurate? Jan 12, 2019 at 13:09
  • 1
    No, there are always edge cases. There just is no 100% reliable way. Your answer is fine. Jan 12, 2019 at 15:23
  • SpiceWeasel if you could send me a screenshot of how it should work. and add the commands along with the screenshot and could you number the commands and in the screenshot like put a sign on them that say the number. when you said put it in a repeating chain thats when i got lost because im not a redstone person
    – WolfGod303
    Jan 12, 2019 at 16:35
  • Ah. Alright, I'll do that as soon as I can get on minecraft again, but the wait could last until tomorrow or Monday. A repeating chain is just a repeating command block powering a line of chain command blocks (/give @s repeating_command_block, /give @s chain_command_block) Jan 12, 2019 at 17:26

You must log in to answer this question.

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