|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|