-- Context -- This script is being used to spawn zombies on spawnPads when a BoolValue called ZombiesReady is set to true. When testing the script, my ZombiesReady is set to true correctly, and the ZombiesYTS value is 10, but no zombies are spawning, or even being cloned from the TemplateZombie in the Lighting. There are no errors in the output, I assume the issue is with this snippet of code:
if ZombiesReady.Value == true then ZombiesReady.Value = false for i = 1, ZombiesYTS.Value do wait(math.Random(1, 18) * RoundNum.Value) local Zombie = game.Lighting.TemplateZombie:Clone()
Thanks guys for being so darn good at figuring out whats wrong with my scripts. You guys are the lifeblood of the community, and I am sure you can figure this one out.
while true do
if ZombiesReady.Value == true then
ZombiesReady.Value = false
for i = 1, ZombiesYTS.Value do
wait(math.Random(1, 18) * RoundNum.Value)
local Zombie = game.Lighting.TemplateZombie:Clone()
Zombie.Name = " "
Zombie.Enemy.MaxHealth = 100 * RoundNum.Value
Zombie.Enemy.Health = Zombie.Enemy.MaxHealth
local choices = game.spawnPads:GetChildren()
local teleportto = (choices[math.random(1,#choices)])
if teleportto~=nil then
local torso = Zombie.Torso
local location = teleportto.Position
local x = location.x
local y = location.y
local z = location.z
x = x
z = z
y = y
local cf = torso.CFrame
local lx = 0
local ly = y
local lz = 0
torso.CFrame = CFrame.new(Vector3.new(x,y,z), Vector3.new(lx,ly,lz))
Zombie.Parent = game.Workspace
end
end
end
wait(.1)
end
And this is the rest, before the script
local ZombiesKilled = game.Workspace.ZombiesKilled
local ZombiesYTS = game.Workspace.ZombiesYetToSpawn
local RoundNum = game.Workspace.RoundNumber
local ZombiesRequiredToKill = 0
local ZYTSlast = 0
local ZombiesReady = game.Workspace.ZombiesReady
local ZYTSmultiplyer = 1.4
function gameStart()
print ("Loaded")
ZombiesYTS.Value = 10
ZombiesRequiredToKill = ZombiesYTS.Value
ZombiesKilled.Value = 0
ZYTSlast = 10
RoundNum.Value = 1
wait(3)
ZombiesReady.Value = true
end
gameStart()
while true do
if ZombiesRequiredToKill == ZombiesKilled.Value then
RoundNum.Value = RoundNum.Value + 1
ZombiesYTS.Value = ZYTSlast * ZYTSmultiplyer
wait(.1)
ZYTSlast = ZombiesYTS.Value
ZombiesRequiredToKill = ZombiesYTS.Value
ZombiesReady.Value = true
end
wait(.1)
end

3 comments
math.random, not math.Random.
Thanks, but it still is not working...
Nevermind, I got it to work with a few fixes!