#how do i detect deaths?

1 messages · Page 1 of 1 (latest)

vale trail
#

world.afterEvents.entityDie.subscribe(eventData => {
const deadEntity = eventData.deadEntity;
if (deadEntity?.typeId !== 'minecraft:player') return;

const damagingEntity = eventData.damageSource.damagingEntity;
deadEntity.runCommandAsync(/scoreboard players add @s deaths 1);
if (!damagingEntity) return;
damagingEntity.runCommandAsync(/scoreboard players add @s kills 1);
});

#

you’ll need to mess around with it

#

to work with armour stands

#

but that’s how you track kills and deaths

vale trail
#

hey use this, i didn’t get the error you got but i fixed whatever errors i did get


import { world, system } from "@minecraft/server"

world.afterEvents.entityDie.subscribe(data => {
    const deadEntity = data.deadEntity;
    if (deadEntity?.typeId !== 'minecraft:player') return;
    const damagingEntity = data.damageSource.damagingEntity;
    world.sendMessage(`${deadEntity.name} took the L`);
});```
#

if your looking to actually change the death messages look into the lang files for that