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

Why do the zombies keep respawning?

Asked by 9 years ago

I am making a game with multiple waves, and the next wave doesnt start until all of the zombies are permanently dead, I have a script inside of the model that checks if the player is dead it sets a int value to 1, then in another script ( game loop script ) it checks if the value is 1 and starts the new wave. I don't want the zombies to keep respawning but they do.

Here is the code to both of the scripts.

Game Loop Script

target = CFrame.new(558.5, 130.1, 19)
target2 = wait
while true do

wait(20)
local m = Instance.new("Hint", game.Workspace)
m.Text = ("A new round is starting in 20 seconds.")
wait(10)
m.Text = ("A new round is starting in 10 seconds.")
wait(5)
m.Text = ("A new round is starting in 5 seconds.")
wait(1)
m.Text = ("A new round is starting in 4 seconds")
wait(1)
m.Text = ("A new round is starting in 3 seconds")
wait(1)
m.Text = ("A new round is starting in 2 seconds")
wait(1)
m.Text = ("A new round is starting in 1 seconds")
wait(1)
m.Text = ("Loading map, this may lay your game a bit...")
game.Lighting.Desserted.Parent = game.Workspace
wait(5)
m.Text = ("Map loaded!")
wait(3)
m.Text = ("Teleporting the players and giving them the tools.")
for i, player in ipairs(game.Players:GetChildren()) do
    player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0)
end
wait(2)
m.Text = ("Round 1 will start in 15 seconds")
wait(10)
m.Text = ("Round 1 will start in 5 seconds")
wait(1)
m.Text = ("Round 1 will start in 4 seconds")
wait(1)
m.Text = ("Round 1 will start in 3 seconds")
wait(1)
m.Text = ("Round 1 will start in 2 seconds")
wait(1)
m.Text = ("Round 1 will start in 1 second")
wait(1)
m.Text = ("Teleporting zombies")
local clone = game.Lighting.Wave1:Clone()
clone.Parent = game.Workspace
clone.Name = "clonewave1"
wait(3)
m.Text = ("Giving players their tools.")
for u, playerz in ipairs (game.Players:GetChildren()) do
local crowbar = game.Lighting.Crowbar:Clone()
local pistol = game.Lighting.Pistol:Clone()
local paintball = game.Lighting["Paintball Gun"]:Clone()
crowbar.Name = "Crowbar"
pistol.Name = "Pistol"
paintball.Name = "Paintball Gun"
crowbar.Parent = playerz.Backpack
pistol.Parent = playerz.Backpack
paintball.Parent = playerz.Backpack
m.Text = ("Kill all of the zombies to proceed to the next round")
while true do
    if game.Workspace.Defeated.Value == 0 then  
        print("Got to here!!!!")
    else
    if game.Workspace.Defeated.Value == 1 then
        m.Text = "Wave 1 has been defeated."
wait(5)
m.Text = "Get ready for wave 2!"
wait(5)
game.Workspace.Defeated.Value = 0
wait(3)
m.Text = "Wave 2 starting in 10 seconds!"
wait(5)
m.Text = "Wave 2 starting 5 seconds!"
wait(1)
m.Text = "Wave 2 starting in 4 seconds!"
wait(1)
m.Text = "Wave 2 starting in 3 seconds!"
wait(1)
m.Text = "Wave 2 starting in 2 seconds!"
wait(1)
m.Text = "Wave 2 starting in 1 second!"
wait(1)
local clone2 = game.Lighting.Wave2:clone2()
clone2.Name = "clonewave2"
clone2.Parent = game.Workspace
    end
end
end
end
end

Dead player check

while true do
if script.Parent.Parent.Zombie.Humanoid.Health == 0 and script.Parent.Parent.Zombie2.Humanoid.Health == 0 and script.Parent.Parent.Zombie3.Humanoid.Health == 0 and script.Parent.Parent.Zombie4.Humanoid.Health == 0 and script.Parent.Parent.Zombie5.Humanoid.Health ==0 and script.Parent.Parent.Zombie6.Humanoid.Health == 0 and script.Parent.Parent.Zombie7.Humanoid.Health == 0 and script.Parent.Parent.Zombie8.Humanoid.Health == 0 and script.Parent.Parent.Zombie9.Humanoid.Health == 0 then
    game.Workspace.Defeated.Value = 1
end
end

I will edit it if you need where everything is placed.

0
Umm.... I'm hoping you aren't using free models.. If you are.. You might want to go into the script that deals with them respawning... lomo0987 250 — 9y
0
Honestly, I have deleted the respawn script, I havn't tested it yet. DevShowcase 0 — 9y

Answer this question