|
| 08 Jun 2014 03:56 AM |
just a simple question guys!
this is how things go: game.Workspace.Model.Part.Items --items is an object value
if i used game.Workspace:GetChildren()
will one of the children be the Part or Items? if not, how do I make it search for the children of the children. |
|
|
| Report Abuse |
|
|
YeahNick
|
  |
| Joined: 28 Feb 2009 |
| Total Posts: 2536 |
|
|
| 08 Jun 2014 04:02 AM |
| :GetChildren() returns a table of an object. If you did Workspace:GetChildren() then 'Model' would be in that table. For your instance you would need game.Workspace.Model:GetChildren(), although 'Items' would not be a direct child, because its parent is not 'Model'. |
|
|
| Report Abuse |
|
|
|
| 08 Jun 2014 04:03 AM |
| But what if i want to get ALL the children of workspace? is there some sort of function like getchildren like that? |
|
|
| Report Abuse |
|
|
|
| 08 Jun 2014 04:05 AM |
basically what im trying to do right now is i have a model with lots of models with parts inside, i want to get all the children of the main model.
Main Model (inside main model) model with parts model2 with parts model3 with parts
how do i use any function that will get ALL the children of mainmodel including all its parts. |
|
|
| Report Abuse |
|
|
YeahNick
|
  |
| Joined: 28 Feb 2009 |
| Total Posts: 2536 |
|
|
| 08 Jun 2014 04:10 AM |
Sorry, but there isn't an easy method for that. Fortunately though, there's a user created method:
function GetDescendants(instance) getfenv()['_d'] = {} if (type(instance) ~= "userdata") or (not pcall(function() return instance['Name'] end)) then error("GetDescendants requires an object.") end local function Get(parent) for i,v in pairs(parent:GetChildren()) do if (#v:GetChildren() > 0) then Get(v) end end end Get(instance) return _d end
An example for use of this function would be this: local table = GetDescendants(Workspace) |
|
|
| Report Abuse |
|
|