• Hey! Register here to create your account, engage with the community, and talk about what is new!

How do I detect who killed a mob when they didn't physically kill it themselves

luapus

New member
Joined
Jul 17, 2021
Messages
3
Reaction score
0
I coded some sort of projectile using variables that trigger an explosion when it hits a mob. I want to implement a token system where the player gets a token whenever they kill a mob. However, when the projectile kills a mob with its explosion it doesn't count as the player that fired the projectile's kill. How can I make it so it does? (also if there is a way to spawn an instantly exploding creeper I might be able to work around it, so tell me if this is possible)
 

ARMcPro

Forum adept
Overlord
Joined
Oct 20, 2020
Messages
1,245
Reaction score
349
Instead of summoning an explosion spawn a tnt using GameAction: Spawn Primed TNT with 0 fuse and call the TNT the same as the player name (so call it %shooter) and on EntityDamagePlayer event check if the Damage is equals or more than the player's health, inside the brackets you can select Players by name and put %damager and it should select the attacker then you can give them a token
 
Last edited:

Fghj240

Active member
Joined
Jun 5, 2021
Messages
53
Reaction score
8
I coded some sort of projectile using variables that trigger an explosion when it hits a mob. I want to implement a token system where the player gets a token whenever they kill a mob. However, when the projectile kills a mob with its explosion it doesn't count as the player that fired the projectile's kill. How can I make it so it does? (also if there is a way to spawn an instantly exploding creeper I might be able to work around it, so tell me if this is possible)
if you're using game action to shoot the projectile, use player action instead. If that doesn't work do what ARMcPro said which is instead of creating an explosion summon a tnt with no fuse that instantly explodes so its the same thing but you rename the tnt to the player who shot it's name and you can detect who has the same name as the tnt.

If you're using a custom explosion that damages entities with the damage action then I don't know.
 
Top Bottom