|
| 24 Aug 2016 11:40 AM |
Okay so I am trying to put a cap on how many "Zombies" can be in the workspace at one time. I have them go inside a model named "localZombies", and I am trying to put a spawn cap on it so that there can not be more than 25-50 (math.random) zombies at a time in the workspace at one time.
Here's the code
-- Zombie spawn service, created by PheonixActual 8/22/16
-- Variables local ServerS = game:GetService("ServerStorage")
local Zombies = ServerS:WaitForChild("Zombies")
local Zombie = Zombies:WaitForChild("Drooling Zombie")
local wZombies = game.Workspace:WaitForChild("localZombies")
local children = wZombies:GetChildren()
local zombiesCanSpawn = true
local workspaceChildren = game.Workspace:GetChildren()
-- Functions
function spawnZombie() -- Spawns the zombies, which I am trying to put a cap on
while true do wait(math.random(2)) print("Zombie was spawned") local clone = Zombie:Clone() clone.Parent = wZombies end end
spawnZombie() -- Call's the function
for i,v in pairs(wZombies:GetChildren()) do -- Here I am trying :GetChildren() stuff print(#wZombies) wait(1) end
If you can help, it would be GREATLY appreciated.
Thanks, Pheo |
|
|
| Report Abuse |
|
|
|
| 24 Aug 2016 11:58 AM |
local children = workspace:GetChildren() for i = 1, #children do print(i, children[i].Name) end this is an example from roblox wiki work from here |
|
|
| Report Abuse |
|
|
|
| 24 Aug 2016 01:17 PM |
Helped somewhat, I have been attempting to figure it out for 2 hours and I have gotten nowhere.
Help?
Thanks, Pheo |
|
|
| Report Abuse |
|
|