I am guessing you have this in a repeating command block. When run this way, if there are currently no dead players, the "error" the command block will output is:
Entity '@p[score_health_min=0,score_health=0]' cannot be found
This is functioning properly. Your commands work properly as is, there is nothing wrong with them. The only time this output would be different is if you were to click on the command block while there was a dead player who had not respawned.
I have a few suggestions though:
- Unless you are doing something very specific needing to target only the closest player, use
@a instead of
@p as this will make it multiplayer capable.
- As you are testing for a number at or below 0, you do not need to use the minimum argument.
- The testfor command is not all that useful, you can use the target selector in a command that actually does something useful instead.
An example command with the suggested target selector to make the dead player say hello:
execute @a[score_health=0] ~ ~ ~ say Hello
Note: This will repeat until the dead player respawns so chat would be filled will a player saying hello.
This can be overcome by having a conditional chain command block with command:
scoreboard players reset @a health
Another way of doing it, use the deathCount criteria. This will allow you to test for a minimum score of 1.
Command to create the objective:
/scoreboard objectives add Deaths deathCount
Then two command blocks. The first a Repeat Unconditional Always Active with command:
execute @a[score_Deaths_min=1] ~ ~ ~ say hello
The second a Chain Conditional Always Active with command:
scoreboard players reset @a Deaths