TransWikia.com

How can I use commands to give an item to the person who killed a player?

Arqade Asked by Hamouda Rashwan on February 22, 2021

For example, if player A killed player B, how can I make it so player A gets a specific item using commands? ~~~{if you killed A player you will get diamond,if you kill B player you will get emerald for example

I tried these commands but it gives all player the same item + I want a specific player is killed

Commands:
To get a command block –

/give USERNAME minecraft:command_block

To create the first scoreboard –

/scoreboard objectives add Kills playerKillCount

To create the second scoreboard –

/scoreboard objectives add Count playerKillCount

To add the first scoreboard to the side bar –

/scoreboard objectives setdisplay sidebar Kills

First command block:
For diamonds –

/give @p[scores={Count=1..]} minecraft:diamond 1

For emeralds –

/give @p[scores={Count=1..]} minecraft:emerald 1

For XP –

/xp add @p[scores={Count=1..]} 1 levels

Second command block:

/scoreboard players reset @p[Scores={Count=1..]} Count

To clear kill sidebar:

/scoreboard players reset @a Kills

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP