Minecraft – How to detect which specific mob was killed by a player and increase a score accordingly

minecraft-commandsminecraft-java-edition

I'm making a Tower Defense map and my score system is pretty simple, whenever you kill a zombie the 'Money' scoreboard gets 1 more score.

I used the command

/scoreboard objectives add Money stat.killEntity.Zombie Money

to set up the counter for that.

In my map there are different zombies, some have got more health then others. My problem is, all the different zombies give as much Money. So if the player kills a zombie of Lvl 1 or Lvl 12, the players always just gets 1 money. All the zombies are summoned with a '/summon' command and my solution to this was to give the different zombies different names and somehow make the scoreboard track down what zombie the player killed. (It will check the name of the zombie that has been killed)

Does someone know how? Or an easier or better way? I would highly appreciate it! I've got this problem for a while now and I cant make progress because of this. If someone can help me I'll credit him/her in my map.

Best Answer

If your map is not going to be multiplayer, you may want to consider tracking if each zombie spawned is alive by attempting to execute commands on them and checking if said commands succeed.

Another solution, which I think is probably the best, is to implement custom loot from the different zombies that you spawn, perhaps paper or gold that is renamed to different values, or just different drops from each enemy, that are then automatically cleared from the players' inventories in exchange for scoreboard points.

Related Topic