Well then the "zomb" element doesn't exist.
To prevent the errors you can put a check if "zomb" is an element in both the timer function and the respawnZombieInTime function and stop the execution of the function with "return".
Something like this:
function respawnZombieInTime ( zomb, immediatly )
if not isElement(zomb) then
return
end
if exports.npc_hlc:isHLCEnabled ( zomb ) then
exports.npc_hlc:disableHLCForNPC (zomb)
end
--if isElement ( getElementData ( zomb, "zombieShape" ) ) then destroyElement ( getElementData ( zomb, "zombieShape" ) ) end
--if isElement ( getElementData ( zomb, "shapeFar" ) ) then destroyElement ( getElementData ( zomb, "shapeFar" ) ) end
local resptimer = timeToRespawnZombie
if immediatly then
resptimer = 20000
end
setTimer ( function ( shape, zomb )
if not isElement(zomb) then
return
end
local attaches = getAttachedElements ( zomb,1)
if attaches then
for ElementKey, ElementValue in ipairs ( attaches ) do
if isElement ( ElementValue ) then
destroyElement ( ElementValue )
end
end
end
destroyElement ( zomb,1)
aliveZ = aliveZ - 1 -- this seems to be useless ??
if isElement ( shape ) then
setElementData ( shape, "zSpawned", false )
setElementData ( shape, "zombie", false )
end
end,resptimer, 1, getElementData ( zomb, "spawnShape" ), zomb )
--setElementData ( root, 'zombiesalive', getElementData ( root, 'zombiesalive' )-1 )
end