Why isn't this working??


EntHealth = 5
 
 function ENT:OnTakeDamage(dmg)
 
    if(EntHealth <= 0) then return end
 
    EntHealth = EntHealth - 1
 
    if(EntHealth <= 0) then
        self:SetModel("models/zavod_yantar/zabor_metal_1.mdl")
    end

     end


I have this code in the init.lua file of an entity. It works like 10% of the time, but the other 90% it does not. The model very rarely changes after 5 hits. Can someone point out the retarded mistake I’ve made? Thanks.