Seems you messed up something. Anyway I have a fixed version.
exports["scoreboard"]:addScoreboardColumn("zombieKills", root, 80, "Zombmoanie-Kills",80) local ZombiePedSkins = {22,56,67,68,69,70,84,92,97,105,107,108,111,126,127,128,152,162,167,188,192,195,206,209,212,229,230,258,264,274,277} --ALTERNATE SKIN LISTS FOR ZOMBIES (SHORTER LIST IS TEXTURED ZOMBIES ONLY) local ZombieLimit = 50 -- HOW MANY ZOMBIES SHOULD EXIST AT MAXIMUM? local ZombieStreaming = 1 -- 1 to constantly stream zombies, 0 to only allow zombies to spawn via createZombie function, 2 to only allow spawning at set spawnpoints local ZombieSpeedCheck = 400 local chaseanim = "run_old" local checkspeed = 500 local count = 0 local moanlimit = 10 local everyZombie = { } local zombieblip = { } --RESOURCE START/INITIAL SETUP addEventHandler("onResourceStart", resourceRoot, function ( ) local timer = ZombieSpeedCheck for _,thePlayer in ipairs(getElementsByType("player")) do setElementData(thePlayer, "dangercount", 0) end MainTimer1 = setTimer(setangle, timer, 0) -- KEEPS ZOMBIES FACING THE RIGHT DIRECTION MainTimer3 = setTimer(triggerEvent, 3000, 0, "onClearFarZombies", root) --KEEPS ALL THE ZOMBIES CLOSE TO PLAYERS MainTimer2 = setTimer(triggerEvent, 2500, 0, "onPreZombieSpawn", root, 2500, 0) --Spawns zombies in random locations end) --SETS THE ZOMBIE ACTIVITY WHEN STATUS CHANGES addEventHandler("onElementDataChange", root, function (dataName) if (getElementType(source) == "ped") and (dataName == "status") then if (getElementData(source, "zombie")) then if not (isPedDead(source)) then if (getElementData(source, "status") == "chasing") then local Zx, Zy, Zz = getElementPosition(source) local newtarget = getElementData(source, "target") if (isElement(newtarget)) then if (getElementType(newtarget) == "player") then setElementSyncer(source, newtarget) end Zx, Zy, Zz = getElementPosition(newtarget) end setTimer(setZombieChase, 1000, 1, source, Zx, Zy, Zz) elseif (getElementData(source, "status") == "idle") then setTimer(setZombieIdle, 1000, 1, source) --[[elseif (getElementData ( source, "status" ) == "throatslashing" ) then local tx,ty,tz = getElementPosition( source ) local ptarget = getElementData ( source, "target" ) if isElement(ptarget) then local vx,vy,vz = getElementPosition( ptarget ) local zombdistance = (getDistanceBetweenPoints3D (tx, ty, tz, vx, vy, vz)) if (zombdistance < . then triggerClientEvent("onZombieControl", source, "moan", math.random(moanlimit)) setPedAnimation ( source, "knife", "KILL_Knife_Player", -1, false, false, true) setPedAnimation ( ptarget, "knife", "KILL_Knife_Ped_Damage", -1, false, false, true) setTimer ( Playerthroatbitten, 2300, 1, ptarget, source) setTimer ( function (source) if ( isElement ( source ) ) then setElementData ( source, "status", "idle" ) end end, 5000, 1, source ) else setElementData ( source, "status", "idle" ) end else setElementData ( source, "status", "idle" ) end]] end elseif (getElementData(source, "status") == "dead") then setTimer(destroyElement, 10000, 1, source) end end end end) --CLEARS A DEAD ZOMBIE addEventHandler("onElementDestroy", resourceRoot, function ( ) if (getElementType(source) == "ped") and (getElementData(source, "zombie")) then for theKey,thePed in ipairs(everyZombie) do if (source == thePed) then table.remove(everyZombie, theKey) break end end if (zombieblip[source]) then destroyElement(zombieblip[source]) zombieblip[source] = nil end end end) --DELETES ZOMBIES THAT ARE TOO FAR FROM ANY PLAYERS TO KEEP THEM MORE CONCENTRATED WHILE STREAMING ZOMBIES addEvent("onClearFarZombies", true ) addEventHandler("onClearFarZombies", root, function () if (ZombieLimit) then local toofarzombies = { } local allplayers = getElementsByType("player") for ZombKey,theZomb in ipairs(everyZombie) do if isElement(theZomb) then if (getElementData (theZomb, "zombie") == true) then local Zx, Zy, Zz = getElementPosition( theZomb ) for theKey,thePlayer in ipairs(allplayers) do local Px, Py, Pz = getElementPosition(thePlayer) local distance = getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) if (distance > 75) then if not (getElementData(theZomb, "forcedtoexist")) then destroyElement(theZomb) end end end if far == 1 then table.insert( toofarzombies, theZomb ) end end else table.remove(everyZombie, ZombKey) end end end end) --HEADSHOTS addEvent("headboom", true) addEventHandler("headboom", root, function (ped,attacker, weapon, bodypart) if (getElementData(ped, "zombie") == true) then killPed(ped, attacker, weapon, bodypart) setPedHeadless(ped, true) end end) --KILL FROM ZOMBIE ATTACK addEvent("onZombieKillPlayer", true ) addEventHandler("onZombieKillPlayer", getRootElement(), function (player, weapon, bodypart) killPed(player, source, weapon, bodypart) end) --CHECKS FOR ZOMBIE GRABBING FROM BEHIND function Playerthroatbitten ( player, attacker) local Zx, Zy, Zz = getElementPosition( attacker ) local Px, Py, Pz = getElementPosition( player ) local distance = (getDistanceBetweenPoints3D( Px, Py, Pz, Zx, Zy, Zz )) if (distance < 1) then killPed ( player, attacker, weapon, bodypart ) else setPedAnimation (player) end end --ADJUSTS PLAYERS ZOMBIE KILL SCORE addEventHandler("onPedWasted", resourceRoot, function (ammo, attacker, weapon, bodypart) if (attacker) then if (getElementType ( attacker ) == "player") and (getElementType ( source ) == "ped") then if (getElementData (source, "zombie") == true) then triggerEvent ( "onZombieWasted", source, attacker, weapon, bodypart ) local zkill = exports["ZA-export"]:getPlayerZKill(attacker) if (zkill) then local attackerName = getPlayerName(attacker) local ar, ag, ab = getPlayerNametagColor(attacker) setElementData(attacker, "zombieKills", zkill+1) exports["ZA-account"]:setAccountData(attacker, "zombieKills", zkill+1) givePlayerMoney(attacker, math.random(100,300)) exports["ZA-level"]:givePlayerExp(attacker, math.random(2,10)) exports.killmessages:outputMessage({attackerName,{"padding",width=3},{"icon",id=weapon or 0},{"padding",width=3},{"color",r=162,g=0,b=0},"Zombie"}, getRootElement(), ar, ag, ab) end end end end end) addEventHandler("onPlayerLogin", getRootElement(), function (_,account) local zombieKills = exports["ZA-account"]:getAccountData(source, "zombieKills") if (zombieKills) then setElementData(source, "zombieKills", zombieKills) end end) addEventHandler("onVehicleStartEnter", root, function (thePlayer) if (exports["ZA-export"]:isPlayerInTeam(thePlayer, "Zombies")) then cancelEvent() exports["ZA-hud"]:createNewHelpMessageForPlayer(enteringPlayer,"You'r zombie stupid don't know how to drive", 255, 0, 0) end end) --SPAWN ZOMBIE (now can be cancelled!) addEvent("onZombieSpawn", true ) addEventHandler("onZombieSpawn", root, function (gx, gy, gz, rot) if not hasPositionZombieProof(gx, gy) and (#everyZombie < ZombieLimit) then local rot = rot or math.random(360) local skin = tonumber(ZombiePedSkins[math.random(#ZombiePedSkins)]) local zombie = createPed(skin, gx, gy, gz, rot) if (zombie) then zombieblip[zombie] = createBlipAttachedTo(zombie, 0, 1, 160, 0, 0, 255, 0, 100) setElementData(zombie, "zombie", true) setElementData(zombie, "status", "idle") setPedWalkingStyle(zombie, 120) table.insert(everyZombie, zombie) triggerClientEvent("onZombieControl", zombie, "moan", math.random(moanlimit)) triggerClientEvent("onZombieControl", zombie, "stfu") end end end) --SPAWNS ZOMBIES RANDOMLY NEAR PLAYERS addEvent("onPreZombieSpawn", true ) addEventHandler("onPreZombieSpawn", root, function () local pacecount = 0 while pacecount < 5 do --4 ZOMBIES AT A TIME TO PREVENT FPS DROP local tzombiecount = #everyZombie+pacecount if (tzombiecount < ZombieLimit) then local livePlayers = getAlivePlayers() if (#livePlayers > 0) then local lowestcount, lowestguy = 99999, nil for _, thePlayer in ipairs(livePlayers) do local dangercount = getElementData(thePlayer, "dangercount") or 0 if (dangercount < lowestcount) and not (getElementData(thePlayer, "zombieProof")) then local gx, gy, gz = getElementPosition(thePlayer) if not hasPositionZombieProof(gx, gy) then lowestcount, lowestguy = dangercount, thePlayer end end end pacecount = pacecount+1 if (isElement(lowestguy)) then local disc, angle = math.random(15, 50), math.random(360) local ycoord, xcoord = getDistanceRotation(0, 0, disc, angle) triggerClientEvent("onClientPreZombieSpawn", lowestguy, ycoord, xcoord) else pacecount = pacecount+1 end else pacecount = pacecount+1 end else pacecount = pacecount+1 end end end) --IDLE BEHAVIOUR OF A ZOMBIE function setZombieIdle (ped) if (isElement(ped)) and not (isPedDead(ped)) then if (getElementData(ped, "status") == "idle") and (getElementData(ped, "zombie")) then local action = math.random(6) if (action > 2) then -- walk a random direction