Make the npcs immortal?

Is there any way to make npcs immortal? So they can not be killed.

I have tried to change the health, i have also tried to hook it to a scalenpcdamage, so they get health everytime they get damage.
I have tried to change the scale of the damage to zero too.

Nothing worked.

Can you help me please? Thanks.

this is how i did it


function GM:EntityTakeDamage( ent, inflictor, attacker, amount, dmginfo )
    if ent:IsNPC() then

    local distance = ent:GetPos():Distance(attacker:GetPos())
    local damage = (amount *attacker:GetNWInt("Lvl")/ent:GetNWInt("Lvl"))
                if ent:GetNWInt("npcshield") > 0 then
                ent:SetHealth(ent:Health() + dmginfo:GetDamage()) -- i know you said you tried this but it works for me maybe your doing it in the wrong hook
                ent:SetNWInt("npcshield",ent:GetNWInt("npcshield") - damage
                else
        ent:SetNWString("npchealth",tostring(ent:Health() + amount - damage))
        ent:SetNWString("npcmaxhealth",tostring(ent:GetMaxHealth()))
        ent:SetColor(255,128,128,255)
            end
end

the above code makes any NPC take no damage until its shield is depleted you dont have to make shields, they are custom made for the npcs by me in this case

If you’re making a scripted NPC, just leave out the TakeDamage function.

Else, try the posted example ^