|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 21 Dec 2012 09:16 AM |
| :0 Wrong color but you should get the point... |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|