OnEntityHurt||doc136886

September 20, 2022

Format

local event = Entity:GetEvent("OnEntityHurt")

Description

Triggered event when entity takes damage.

Callback function parameters

Type Name Introduction
Entity endurer Entity that took damage
Entity imposer Entity that caused damage
table<string, variant> damageInfo Damage details

Entity that caused damage and entity that took damage may be the same entity

Code Example

local event = Event:GetEvent("OnEntityHurt")
event:Bind(function(endurer, imposer, damageInfo)
    print(imposer .. " damage " .. endurer)
    print(damageInfo.damage, damageInfo.skillName, damageInfo.cause)
end)