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: :GetDescendants() ?

Previous Thread :: Next Thread 
ZachBloxx is not online. ZachBloxx
Joined: 26 Jun 2013
Total Posts: 2833
06 Oct 2013 09:37 PM
Do you think this would be a good method for ROBLOX to add, or would it be a waste since you can easily make a custom function to return a table of all the descendants of an object?

I wouldn't mind if it were to get added, I could see me using it occasionally.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
06 Oct 2013 09:48 PM
Would it return, like:

{Part, Part, {Model Children}}
Or?
Report Abuse
ZachBloxx is not online. ZachBloxx
Joined: 26 Jun 2013
Total Posts: 2833
06 Oct 2013 09:51 PM
Just a table of all the descendants of the object the method is being used on.

For example:

for i,v in next, Workspace:GetDescendants() do
print(v)
end

It would print any item that is a descendant of workspace.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
06 Oct 2013 09:54 PM
So any non-model descendents? Otherwise, GetChildren already does that...

Report Abuse
ZachBloxx is not online. ZachBloxx
Joined: 26 Jun 2013
Total Posts: 2833
06 Oct 2013 09:59 PM
:GetChildren() only returns a table of the direct children the method it is being used on.

Try this:

for i,v in next, Workspace:GetChildren() do
print(v)
end

Now try this:

local DescendantsTable = {};
local function GetDescendants(Obj)
for i,v in next, Obj:GetChildren() do
table.insert(DescendantsTable, v)
GetDescendants(v)
end
return DescendantsTable;
end

for i,v in next, GetDescendants(Workspace) do
print(v)
end

They get different results, so GetChildren doesn't do this.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
06 Oct 2013 10:00 PM
Oh, that's what you mean.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
06 Oct 2013 10:00 PM
But you can't do universal things, like:

You can't do GetDescendents... .BrickColor since you will get models, sounds, etc.
Report Abuse
ZachBloxx is not online. ZachBloxx
Joined: 26 Jun 2013
Total Posts: 2833
06 Oct 2013 10:03 PM
I don't quite understand what you mean by that.

for i,v in next, Workspace:GetDescendants() do
if v:IsA('BasePart') then
v.BrickColor = BrickColor.new('Bright red')
end
end

?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
06 Oct 2013 10:31 PM
Oh, so it just returns all descendants in 1 table, no matter where it is.
Yeah, I guess that could work
Report Abuse
As8D is online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
07 Oct 2013 05:04 AM
That is an goo... I mean evil idea, I like it.

Yes, we can make stuff that acts like your idea, but I'd say it makes things way easier having a method like that - Then the only question is efficiency?

- Evil As, got idea for ze AssetService. :I
Report Abuse
SCP087Project is not online. SCP087Project
Joined: 29 Sep 2013
Total Posts: 198
07 Oct 2013 09:25 AM
It's a good idea for ROBLOX to add commonly used methods to their API officially, to both increase the speed of our scripts and increase the readability.
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