Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Game lagging when Zombies get tagged or spawn in?

Asked by 2 years ago

so i have this script that activates a "insta-kill" power up. when the player grabs it it works fine. if the power up is still active when the next round starts the game lags incredibly bad as the zombies spawn in and stops when the power deactivates. this is weird to me cause if all the zombies are loaded in the game runs fine, its just when they spawn in it drops to 8 - 11 FPS

heres the code. i also added in a wait(2) to try to fix it but nothing happened.

local CS = game:GetService("CollectionService")
local temp = CS:GetTagged("Zombie")

    for i, v in pairs(temp) do
        if v:IsA("Model") then
            local Hum = v:FindFirstChild("Humanoid")
            if Hum then

            Hum.Health = 1
            wait(2)

        else
print "nil"
            end
        end
    end


Answer this question