Give player item(s) when player hits X amount of deaths

I'm making a game where you have to destroy the most blocks possible, but some blocks can kill you so if you die too many times or whatever the threshold is set to you get an item to give you advantage over other players. There will be a max of 4 people but i want them to each have their own death count so it gives the items to that specific person but the command block can't tell who died and when to give the item to them, which is why I am trying to set each player with a objective manually because I will be playing with my friends.

So far I have gotten to the phase of the commnd block, where it works by giving me the item, but the testfor I made keeps searching for me again because i still have those deaths counted. That's why i need to somehow then reset the objective, but I can't.

Basically I want to make it so when you die X amount of times you get some item(s) when you hit X deaths, but no matter how many times I try and add the proper console commands in some tutorial videos they don't work, example:

/scoreboard objectives add PlayerKills playerKillCount

Changing player kills to Deaths and playerKillCount to deathCount then using this command in the actual command block:

/give @a [score_Deaths_min=1] iron_sword

I fixed the problem thanks i created different teams put the players on different teams then created objectives for each player and set them each to their deathCount and made everytime testfor found 5 deaths it reset the deaths and gave them items.


Solution 1:

Your first command is fine if you are changing it as you say.

The problem appears to be that you have a space between the selector (@a) and the selector arguments ([score_Deaths_min=1]), when there shouldn't be one. Try this command instead:

/give @a[score_Deaths_min=1] iron_sword

Solution 2:

Simple, just use the deathCount criteria for your scoreboard objective.

/scoreboard objectives add Deaths deathCount Deaths

Then use the command:

/give @a[score_Deaths_min=(Desired Amount)] (Item) (Amount) (Data Value) {Data Tag}