#Check for damage given by Player

1 messages · Page 1 of 1 (latest)

clear lark
#

Hey guys so I wanted to know if we can somehow check if the Player hurts another entity?

steep lark
#
    if (ev.damageSource.damagingEntity.typeId instanceof Player) {
        const dmg = ev.damage;
        ev.damageSource.damagingEntity.sendMessage(`You Dealt ${dmg}`)
    }
})```
dreamy marsh
#

Wrong

dreamy marsh
rigid dagger
#

To be explicit with what was wrong: The typeId property is always a string. Perhaps you meant to do either of the following conditions:
ev.damageSource.damagingEntity.typeId == "minecraft:player"
ev.damageSource.damagingEntity instanceof Player

clear lark
#

Thanks guys!