Jump to content

Execute monsters below a certain HP


Recommended Posts

How can you make a weapon execute a mob below a certain HP threshold? I've got this so far: 

local function onattack(inst, attacker, target)
    if target.health and target.components.health.currenthealth < 100 then
        target.components.health:Kill()
    end
end

Is it possible to add percentages to this as well? Like 25% health for example. Thanks!

Link to comment
Share on other sites

local function onattack(inst, attacker, target)
    if target.health ~= nil and target.components.health:GetPercent() < (target.components.health.maxhealth*0.25) then
        target.components.health:Kill()
    end
end

That oughta do it

 

EDIT  target.components.health.currenthealth < (target.components.health.maxhealth*0.25) would probably work better. Lmao

Edited by Mr. Tiddles
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...