How do I detect when a player kills a mob in Minecraft using commands? [duplicate]
So I am making a function for a video, and I need a way to set a player's score to 1 when they kill a bat.
I was thinking I could just summon an invisible armor stand on every bat in the overworld, and use that to detect if a bat died near a player. However that could be very buggy, and may lag some users games.
Anyone got any alternatives?
Solution 1:
You can create an objective with the minecraft.killed:minecraft.bat
which will automatically increment each time you kill a bat.
/scoreboard objectives add batKills minecraft.killed:minecraft.bat