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 » Scripting Helpers
Home Search
 

Re: How do I get 100% of all children of a model?

Previous Thread :: Next Thread 
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
19 Jan 2014 06:31 PM
I dont want to do for statements for how many models I have inside this model. I need something that goes though all the models, no matter how many I have?
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
19 Jan 2014 06:33 PM
GetAllChildren()
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
19 Jan 2014 06:34 PM
... I wish I would have known this 2 hours ago...

Are you sure it gets ALL of them?
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
19 Jan 2014 06:34 PM
Get*All*Children() ._.
Report Abuse
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
19 Jan 2014 06:35 PM
function FindChildren(Where)
local S = {}
for _,n in pairs(Where:GetChildren()) do
S[#S+1] = n
--wait() --Might be needed in a very very big model.
FindChildren(n)
end
end


local Children = FindChildren(Workspace.Model)
Report Abuse
Azarth is not online. Azarth
Joined: 17 Aug 2012
Total Posts: 2760
19 Jan 2014 06:36 PM
There is no GetAllChildren().

function all(obj)
for i,v in pairs(obj:GetChildren()) do
v.Name = "HI"
all(v)
end
end

all(Workspace)
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
19 Jan 2014 06:36 PM
Thank you!
Report Abuse
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
19 Jan 2014 06:38 PM
Oops

function FindChildren(Where)
local S = {}
for _,n in pairs(Where:GetChildren()) do
S[#S+1] = n
--wait() --Might be needed in a very very big model.
FindChildren(n)
end
return S
end
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
19 Jan 2014 06:38 PM
What does the return do?
Report Abuse
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
19 Jan 2014 06:39 PM
It returns a value to where the function was called from.

So:

function MultipliedByTwo(Number)
return Number*2
end

print(MultipliedByTwo(4)) --Would print 8
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
19 Jan 2014 06:41 PM
I still dont get it. Simple, no words just numbers and letters.
Report Abuse
DerProgrammierer is not online. DerProgrammierer
Joined: 16 Aug 2007
Total Posts: 12992
19 Jan 2014 06:43 PM
Return returns the value you are returning.

Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
19 Jan 2014 06:45 PM
Because that makes just PERFECT sense......
Report Abuse
Kevenpowers is not online. Kevenpowers
Joined: 01 Sep 2012
Total Posts: 453
19 Jan 2014 07:57 PM
:D
Report Abuse
ElectricAxel is not online. ElectricAxel
Joined: 15 May 2009
Total Posts: 16239
19 Jan 2014 08:06 PM
If you assign a value to a function that has a 'return in it', the variable will take the 'returned value'. It can also be used immediately in another function or operations though. For example:

Instance.new("blah") RETURNS an object.

math.random() returns a random number.

Now for 2 more vivid examples: (Ignore my ; at the end, habit)

function exFunc()
return 3; --this is the value I'm returning, ALWAYS 3
end

myNumber = exFunc();
print(myNumber); --> 3

But I can simply use the function directly:

print(exFunc()); --> 3


And a calculator:

function add(Num1, Num2)
return Num1 + Num2;
end

myNumber = add(5, 7);
print(myNumber); --> 12

myNumber = add(myNumber, add(3, 5)); --> here we take the value returned from the innermost function (add(3, 5) which is 8) and it replaces the second argument, Num2, so it adds 12 and 8
print(myNumber); --> 20
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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