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

Previous Thread :: Next Thread 
BlizardAlpha is not online. BlizardAlpha
Joined: 23 Aug 2012
Total Posts: 753
21 Dec 2012 09:12 AM
So, I want to get all the children inside this model; turn them all white and hey presto..

How would I do this? I am unfamiliar with the GetChildren() function
Report Abuse
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
21 Dec 2012 09:15 AM
local model = workspace.BlahBlah:GetChildren()
for _,v in pairs(model) do
if v:isA("Part") then
v.BrickColor = BrickColor.new("Green")
end
end
Report Abuse
SolarBreeze is not online. SolarBreeze
Joined: 15 Dec 2012
Total Posts: 606
21 Dec 2012 09:16 AM
I'm not a pro scripter or anything, but here's my attempt :
*MIGHT NOT WORK*

game.Workspace.Model: GetChildren(BrickColor = "")

:p

#yoloswag
Report Abuse
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
21 Dec 2012 09:16 AM
:0 Wrong color but you should get the point...
Report Abuse
Monkey727 is not online. Monkey727
Joined: 12 Jan 2009
Total Posts: 969
21 Dec 2012 09:16 AM

c = script.Parent:GetChildren()

Gets all the children in a table, And stores them in "c".
Then you can add a for loop. #c gets the table length.

for i=1,#c do
if c[i].ClassName == "Part" then
c[i].BrickColor = BrickColor.new("White")
end
end
Report Abuse
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
21 Dec 2012 09:17 AM
? Get children() returns an array/table value so it Must be looped through with some type of for loop.
Report Abuse
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
21 Dec 2012 09:19 AM
Monkey it's more easy to you a "for in pairs" loop then a regular for loop. And I prefer ":isA()" rather than checking the class name.
Report Abuse
Monkey727 is not online. Monkey727
Joined: 12 Jan 2009
Total Posts: 969
21 Dec 2012 09:21 AM
I prefer doing it with a regular for, And I also prefer ClassNames, You stated your opinion and I am stating mine.
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
21 Dec 2012 09:39 AM
What is wrong with people today? I'm seeing more syntax errors than EVER... normally it are logic errors, but today... You guys all are scared because of doomsday or something?
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