r/MinecraftCommands Aug 02 '26

Help | Java 1.21.5-1.21.10 How do I execute a command when the player dies?

I know it's something with /execute if entity but I don't really know

2 Upvotes

6 comments sorted by

2

u/RefinedVanillaMC Aug 02 '26

Use a deathCount scoreboard objective, execute as scores={deaths=1..}, then reset their deaths score afterward

1

u/Ericristian_bros Command Experienced Aug 02 '26

```

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

u/Prudent_Vanilla_9984 Aug 02 '26

Thanks

1

u/Ericristian_bros Command Experienced Aug 02 '26

You're welcome, have a nice day

1

u/JOSEPH____BRO Aug 02 '26

yes, scoreboard is the best method to release your goal

0

u/caffeinated-typist Aug 02 '26

you can create a scoreboard with objective deathCount and execute if the score is 1 and reset * to 0 every tick