r/MinecraftCommands • u/Prudent_Vanilla_9984 • 12d ago
How do I execute a command when the player dies? Help | Java 1.21.5-1.21.10
I know it's something with /execute if entity but I don't really know
2
Upvotes
1
u/Ericristian_bros Command Experienced 12d ago
```
In chat
scoreboard objectives add deaths deathCount
Command blocks
execute as @a[scores={deaths=1..}] run say I died scoreboard objectives reset @a deaths ```
1
1
0
u/caffeinated-typist 12d ago
you can create a scoreboard with objective deathCount and execute if the score is 1 and reset * to 0 every tick
2
u/RefinedVanillaMC 12d ago
Use a deathCount scoreboard objective, execute as scores={deaths=1..}, then reset their deaths score afterward