Zombie spawner only spawning at one place. Why?

Hey there! I am a new developer in Roblox studio and I’m also new to the Roblox DevForm. I am making a zombie survival like game and all was good until this happened.

The Problem

So I was making my Zombie spawners for my game and the problem was, that all of the zombies were spawning at only one place! That two, they were spawning very, very fast. Here is a before and after complication were before i run the game and after I run the game.
Before


And After

As you can see, the zombies are all bunched up in one place and none of the other spawners are not spawning any zombies. Instead, they are spawning only at this one spawn.

You can also see they are spawning REALLY quickly as well.

The Script

This is the script I used in all of the Zombie spawners. (Below) Can someone please tell me how to fix the problem on how to make the other zombie spawns spawn in the other spawners and not only that one spawn, and also tell me how to slow the zombie spawn down. Thanks!

local NPC = game.ReplicatedStorage["Normal Zombie"] -- This is what my zombie model is
local spawner = script.Parent

while true do
  local Clone = NPC: Clone(1) --This is the number on how many zombies should spawn at a time 
 Clone.UpperTorso.CFrame = spawner.CFrame
 Clone.Parent = workspace
 wait(5) -- How long it takes to wait and repeat the script again  
end

Things to Note for Replying

Here is a few things to note down before solving my problem.

  • I do have one model of two parts which have the script and spawner in it. I also used the same model and copy and pasted it in the spawn area. (About 3 or 4 times)
  • The script could only work for R15 Zombie models and were I put the name of the model is the name of the model and it has to be the name of the model or else the script can’t work. (Giving me a better zombie model is nice of you if you give it to me becuase that was the best R15 zombie model i could find. :huh:)
  • Even though I get rid of the zombie spawner that always spawns all of zombies, it still spawns the zombies at that one place!
  • Even though I get rid of all of the spawners and zombies in my game and replicated storage. (The place were i have to put the zombies in order for the zombies to actually spawn) and add them back, the first spawner I make, all of the other zombie spawners will only spawn at the first zombie spawner! And if I get rid of that one, they still spawn at the same place were the spawner was!

That’s it for things to note. :happy1:

Anyways, that is it. Thanks for reading and I appreciate your help if you help me! :derp:

3 Likes

Maybe try putting all the spawners into a table and then choose a random spawner.

local spawners = {} --Insert spawners here
local spawner = spawners[math.random(1,#spawners)]
while true do
   spawner = spawners[math.random(1,#spawners)]
   local Clone = NPC: Clone(1) --This is the number on how many zombies should spawn at a time 
   Clone.UpperTorso.CFrame = spawner.CFrame
   Clone.Parent = workspace
   wait(5) -- How long it takes to wait and repeat the script again  
end
3 Likes

Thanks! Let me try that. :wink:

2 Likes

I made some fixes to it. And dont forget to put all spawners in the table

1 Like

How do I put in a table? Sorry I just dont know because im new.

1 Like

Something like this

local example = {workspace.Part1,workspace.Part2}

Where are the spawners parented to?

1 Like

So does this mean you 3 or 4 spawners, each containing a script that contains the lines of code you posted?

1 Like

The spawners are parented to the workspace. And the zombies are parented to the replicated storage.

1 Like

Yes. I did that and i wanted it to spawn at each spawn but it just spawning at one.

1 Like

Ok so, try to put them in the table.

local spawners = {workspace.Spawner} --Insert the spawns here
1 Like

I’d do what @Dalbertjdplayz suggested, but remove all the scripts in the models and put a single script in Server Storage that clones a zombie and picks a random spawner as the parent.

1 Like

Ok got it. Im trying right now in Roblox studio.

1 Like

Thanks for tell me that @Exodus_Reaper It also helped me!

3 Likes

Hey @Dalbertjdplayz, what do you mean by this.

I don’t understand. Can you help me? :wut:

You don’t really need to know the comment i put.

Oh well I thought it was important becuase I thought I missed out on something becuase for some reason it still not working.

Wait I know what I did wrong. Sorry

Wait now it doesnt work. Instead, the zombies that are already there are there but nothing spawns in. but one zombie is completely still. Why is that? Here is a picture on what im talking about.

Is there a solution to this @Dalbertjdplayz?

You need to make multiple spawns. Therefore, meaning that you have to make different areas for the zombies to spawn. The spawners need to be in the script. The amount of spawners you want should be in the script for it to work. It doesn’t matter how much spawns you want, you just need to count them.