3

So I'm trying to create a scoreboard that tracks the kills of players, but I only want it to increase when they kill a specific player, in this case just the player IGN would do.

I was thinking it would be something like:

/scoreboard objectives add (scoreboardName) minecraft.killed:(player)

but I haven't got it working.

What command should I use?

Btw this is in 1.16.4

1
  • Can you use datapacks? Commented Jan 28, 2021 at 17:50

1 Answer 1

1

By using the minecraft.killed:minecraft.player you can track whenever any player kills a player, if you would combine this with a deathCount on the specific player and test for both scores you can add a dummy score to display kills:

Scoreboards, I used the name kill for when someone has killed a player:

/scoreboard objectives add kill minecraft.killed:minecraft.player

I used the name Death for the specific player's deathCount score:

/scoreboard objectives add Death deathCount

I used the name Kills for the displayed kills:

/scoreboard objectives add Kills dummy

Remember to set scores to 0 to each player:

/scoreboard players set @a kill 0
/scoreboard players set Player Death 0
/scoreboard players set @a Kills 0

I used the name Player for the specific player.

To test for when a player has a kill score of 1 and the specific player has a death count of 1, you can do with this command:

execute as Player if score @s Death matches 1 
run execute as @a if score @s kill matches 1 
run scoreboard players add @a Kills 1

Because the specific player can only be killed by one player, only one player will get a point for the kill score. The command tests for the specific player's death count and any player with a kill, it then gives that player a point in the dummy score Kills.

But you need to reset this as well, you then need to place the last command in a repeating command block and place two chain command blocks after it with these commands:

execute as @a if score @s kill matches 1 run scoreboard players set @s kill 0

This command will reset the kill counter for any player with a score of 1, this will reset even if the specific player is alive, so the Kills score will not change.

Next command:

execute as Player if score @s Death matches 1 run scoreboard players set @s Death 0

This will reset the special player's death counter.

The reason these two last commands is in a chain after the first execute command is so that they run within the same tick but the first one runs first so that the scores don't reset before a point can be added to the Kills score.

You must log in to answer this question.

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