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

Where Is My Error In My Zombie Cloning Script? - (Possible for i = 1, do error)

Asked by
jacobwow 140
8 years ago

-- 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


0
math.random, not math.Random. Perci1 4988 — 8y
0
Thanks, but it still is not working... jacobwow 140 — 8y
0
Nevermind, I got it to work with a few fixes! jacobwow 140 — 8y

1 answer

Log in to vote
0
Answered by
jacobwow 140
8 years ago

Perci1 Solved this in the comments, I just want the post to be solved.

Ad

Answer this question