--almost all of the code here was "borrowed" from Royall's sniper laser script, knowing when you're dead --and properly cleaning up is quite important for any script applied directly to bots. --bots will need EventChangeAttributes with the name "Heal" to work with this script local function removeCallbacks(player, callbacks) if not IsValid(player) then return end for _, callbackId in pairs(callbacks) do player:RemoveCallback(callbackId) end end function CheckGround(_, activator) local callbacks = {} local check local terminated = false local function terminate() if terminated then return end terminated = true timer.Stop(check) removeCallbacks(activator, callbacks) end check = timer.Create(0.015, function() if not IsValid(activator) or not activator:IsAlive() then terminate() return end if activator.m_iDamageDone > 0 then activator:ChangeAttributes("Heal") end, 0) callbacks.died = activator:AddCallback(ON_DEATH, function() terminate() end) callbacks.removed = activator:AddCallback(ON_REMOVE, function() terminate() end) callbacks.spawned = activator:AddCallback(ON_SPAWN, function() terminate() end) end