I am working on a project, and I made a script that will generate x zombies every 30 seconds after all of them are dead, but it’s not working (i checked if the original zombie model works and it does. here’s the script:
local zombieModel = game.Workspace["Drooling Zombie"]
local initialZombiesToSpawn = 10
local spawnInterval = 30
local zombiesToSpawn = initialZombiesToSpawn
while true do
wait(spawnInterval)
local existingZombies = game.Workspace:FindPartsInRegion3(game.Workspace.CurrentCamera.CFrame.Position, Vector3.new(1000, 1000, 1000), nil)
if #existingZombies == 0 then
print("Spawning new wave with", zombiesToSpawn, "zombies")
for i = 1, zombiesToSpawn do
local newZombie = zombieModel:Clone()
newZombie.Parent = game.Workspace
newZombie:SetPrimaryPartCFrame(CFrame.new(Vector3.new(
math.random(-50, 50),
1,
math.random(-50, 50)
)))
end
zombiesToSpawn = zombiesToSpawn + 5
else
print("Waiting for existing zombies to be eliminated...")
end
end
unrelated issue:
also i am using this sword: https://create.roblox.com/marketplace/asset/47433/Sword?keyword=sword&pageNumber=1&pagePosition= which i’ve placed in StarterPack but it acts like it’s anchored. thank you for checking my issues