Can scoreboards detect if a player is killed with a specific item?

[BACK]
Can scoreboards detect if a player is killed with a specific item?
Posted On: March 14, 2024

I'm making a sword that will gain attack damage every time a player gets a kill with it. I think I can get the sword attributes to change based on a scoreboard, but I don't know if I can make a scoreboard that detects if a player is killed by someone using the sword. Does anyone know if this is possible, and if so, how would I do it?


Question from user VeryHotClara at gaming.stackexchange.com.


Answer:

Give yourself an item, for example a sword, include this nbt:.


{customid:"leveling_sword",AttributeModifiers:[{AttributeName:"generic.attack_damage",Name:"generic.attack_damage",Amount:1,Operation:0,UUID:[I;1634486241,408504796,-1808684184,1791120101],Slot:"mainhand"}]}.


It doesn't matter what the UUID is because we will use a custom NBT tag.


Setup commands (run once):.


`/scoreboard objectives add kill playerKillCount kill```\.


For the looped commands you either put them in this order using 1 repeating and multiple chain command blocks, or just use a function in a datapack.


Looped commands:.


/execute as @a[scores={kill=1..},nbt={SelectedItem:{customid:"leveling_sword"}}] run .


/scoreboard players set @a kill 0.


For the part I'm not sure on the exact stuff to do. I know 2 options but I don't have time rn so imma just post this and someone else might have a better idea.


Option one is to replace the first command with /item:.


item modify @a[scores={kill=1..},nbt={SelectedItem:{customid:"leveling_sword"}}] where points to a json file in a loaded datapack.


https://minecraft.wiki/w/Item_modifier.


Option two is to use /data using NBT path format which doesn't require a datapack. However you can't use /data on a player so you first have to move the item to another entity like an armor stand. You might need one armor stand per player in case there are 2 kills on the same game tick. A possibility is to put a marker armor stand on each player's head using /ride.


Answer from user Samstercraft at gaming.stackexchange.com.


[BACK]
Can scoreboards detect if a player is killed with a specific item?
Posted On: March 14, 2024

I'm making a sword that will gain attack damage every time a player gets a kill with it. I think I can get the sword attributes to change based on a scoreboard, but I don't know if I can make a scoreboard that detects if a player is killed by someone using the sword. Does anyone know if this is possible, and if so, how would I do it?


Question from user VeryHotClara at gaming.stackexchange.com.


Answer:

Give yourself an item, for example a sword, include this nbt:.


{customid:"leveling_sword",AttributeModifiers:[{AttributeName:"generic.attack_damage",Name:"generic.attack_damage",Amount:1,Operation:0,UUID:[I;1634486241,408504796,-1808684184,1791120101],Slot:"mainhand"}]}.


It doesn't matter what the UUID is because we will use a custom NBT tag.


Setup commands (run once):.


`/scoreboard objectives add kill playerKillCount kill```\.


For the looped commands you either put them in this order using 1 repeating and multiple chain command blocks, or just use a function in a datapack.


Looped commands:.


/execute as @a[scores={kill=1..},nbt={SelectedItem:{customid:"leveling_sword"}}] run .


/scoreboard players set @a kill 0.


For the part I'm not sure on the exact stuff to do. I know 2 options but I don't have time rn so imma just post this and someone else might have a better idea.


Option one is to replace the first command with /item:.


item modify @a[scores={kill=1..},nbt={SelectedItem:{customid:"leveling_sword"}}] where points to a json file in a loaded datapack.


https://minecraft.wiki/w/Item_modifier.


Option two is to use /data using NBT path format which doesn't require a datapack. However you can't use /data on a player so you first have to move the item to another entity like an armor stand. You might need one armor stand per player in case there are 2 kills on the same game tick. A possibility is to put a marker armor stand on each player's head using /ride.


Answer from user Samstercraft at gaming.stackexchange.com.


[BACK]

how exactly did nocturne become a woman? how exactly did nocturne become a woman?

Posted On: December 11, 2024
Not to be rude but im a divinity player interested in baulders gate so how exactly did it happen is it kinda like elder scrolls where a necromancer goes into a thingy becomes immoble eventually and th...[More]


What is the meaning of the blue icon at the right-top corner in Far Cry: New Dawn? What is the meaning of the blue icon at the right-top corner in Far Cry: New Dawn?

Posted On: August 22, 2023
What is the meaning of the blue icon at the right-top corner in Far Cry: New Dawn? Question from user ÇaÄŸatay KAYA at stackexchange. Answer: These are "Far Cry Credits", a...[More]


How do I give players already enchanted Tools - Armour - Weapons How do I give players already enchanted Tools - Armour - Weapons

Posted On: April 26, 2024
I'm making a map where I want players to be able to choose there kits/classes. The problem I'm having with it though is giving players already enchanted Tools/Armour/Weapons.I'm not sure if you can us...[More]


WHY IS SALAMI A WEAPON?!? WHY IS SALAMI A WEAPON?!?

Posted On: March 25, 2025
i don’t even know what to say…should i start beating up the steel watch with salami now????Question from user Bellaswannabe at BaldursGate3 at reddit.com.Answer:Yes start beating people up with th...[More]


What decisions affect season 2 Walking Dead? What decisions affect season 2 Walking Dead?

Posted On: March 25, 2023
I actually have two base questions. What decisions in Season 1, Episodes 1 through 5, affect 400 days, and in what ways? What decisions from Season 1, and 400 days affect Season 2 Episode 1? ...[More]


The only thing that can revive this game is DLC The only thing that can revive this game is DLC

Posted On: September 2, 2023
There is literally no point in playing after you finish the house cup, I understand that they will probably wait to add DLC until the game is out on switch but it’s been almost 7 months since th...[More]


How do I take down a ufo without damaging it? How do I take down a ufo without damaging it?

Posted On: November 28, 2023
I've been looking for a way to take down a UFO without doing any (or little damage) to it as possible. I haven't found any research that would help me either. My question is, is there some wea...[More]


If your WoW subscription expires, do you go back to Starter Edition? If your WoW subscription expires, do you go back to Starter Edition?

Posted On: April 3, 2024
I've currently got a WoW account that's in "Starter Edition" (or whatever it is they call the free neverending trial, that seems to be the name they use).I'd like to know what happens if I subscribe a...[More]


Why can't I like BG3? Why can't I like BG3?

Posted On: June 1, 2024
I have heard a lot about BG3, and never played it, for many reasons.Yet because it is so popular, I just can’t let it go. “It’s not for me” doesn’t work so well when the game apparently is f...[More]


How to move my save game to another PC in Raft? How to move my save game to another PC in Raft?

Posted On: February 21, 2023
I have a new PC and want to move my Raft saved game. Just copy/paste doesn't seem to work. I'm not using any digital platform or service. Question from user Juan Carlos Oropeza at gaming.st...[More]