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: amount of children in a parent.

Previous Thread :: Next Thread 
redface95 is not online. redface95
Joined: 14 May 2009
Total Posts: 4
26 Feb 2015 08:43 AM
Does anyone know how to make a function to return the number of children a parent has?

function loadInventory ()
for i,v in pairs (game.Players:GetPlayers())do
local amount =tonumber (v.Inventory:GetChildren()
if (amount > 1) then
print ("Amount of children: "..amount)
else
return()
end
end
end

Something along the lines of that.
Report Abuse
ohno1112 is not online. ohno1112
Joined: 23 Mar 2013
Total Posts: 833
26 Feb 2015 08:45 AM
NumberOfChildren = #Model:GetChildren()

really. that's all. :GetChildren() returns a table containing the objects,
the # operator returns the amount of objects inside that table, which equals to
amount of objects inside the parent.
Report Abuse
redface95 is not online. redface95
Joined: 14 May 2009
Total Posts: 4
26 Feb 2015 08:51 AM
Thank you for the fast reply!

That does make things way easier, If only I asked sooner...

Thanks for the help!
Report Abuse
Skyman772 is not online. Skyman772
Joined: 20 Mar 2012
Total Posts: 9305
26 Feb 2015 08:56 AM
function GetNumberOfChildren(parent)
return #parent:GetChildren()
end

GetNumberOfChild(game.Workspace)
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