Minecraft – How to detect if a player out of one team dies

minecraft-commandsminecraft-java-edition

I've got a vanilla server for 1.10 and I already did a scoreboard with two different Teams (red, blue). Now I want to check if either a player on team red or a player on team blue dies and to have a redstone output out of it.

Best Answer

Set up an objective to keep track of deaths:

/scoreboard objectives add Deaths deathCount

To test if a a player on red team had died, run this command:

/testfor @a[team=red,score_Deaths_min=1]

To test if a player on blue team had died, run this command:

/testfor @a[team=blue,score_Deaths_min=1]

You'll then probably need to set their Deaths back to 0 after doing what you want to do:

/scoreboard players set @a[score_Deaths_min=1] Deaths 0