generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: :GetChildren() help

Previous Thread :: Next Thread 
PheonixActual is not online. PheonixActual
Joined: 29 May 2010
Total Posts: 251
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
WrightPhillips99 is not online. WrightPhillips99
Joined: 27 Jun 2015
Total Posts: 667
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
PheonixActual is not online. PheonixActual
Joined: 29 May 2010
Total Posts: 251
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image