so, you are saving a "string" value in that key.
You should do a data type check.
you could remaster the code, as it has some inconsistencies. Remember that the code is executed line by line, doing what we indicate, therefore, we must be logical and specific when programming.
function deanimated( ammo, attacker, weapon, bodypart )
if (attacker) then
if (getElementType ( attacker ) == "player") and (getElementType ( source ) == "ped") then
if (getElementData (source, "zombie") == true) then
local oldZcount = getElementData(attacker, "Zombie kills") or 0 -- get the value, if it has no value, by default, assign value 0 to the variable oldZcount
if (type(oldZcount) ~= "number") then -- added to check the data type that is 'oldZcount', if different from number, (expected value) assign value 0 to the variable oldZcount
oldZcount = 0
end
setElementData(attacker, "Zombie kills", oldZcount + 1)
triggerEvent("onZombieWasted", source, attacker, weapon, bodypart)
end
end
end
end
it is not tested