I have a model that's roughly 10k parts to be used as terrain. When created, they were all gray, plastic parts. How would I get ALL the children of the model, and then change the properties of said children.
I don't want to select each part and change the properties 10,000 times.
I'm not good with :GetChildren()
whatsoever.
Insert this in the model filled with the parts and follow the green text in the script. Oh and +1 dis :D
print("Tochi Was Here") for index,part in pairs(script.Parent:GetChildren()) do if part:IsA("Part") or part:IsA("WedgePart") or part:IsA("CornerWedgePart") then do --do stuff from here : part.BrickColor = BrickColor.Green() part.Material = "Grass" --to here :D end end end
Those 10k parts are in a model right? No one leaves TEN THOUSAND PARTS in Workspace ._.
function Scan(model,tab) -- Scans through EVERY object in (model) if not tab then tab = {} end for _,v in pairs(model:GetChildren()) do if v:IsA("BasePart") then table.insert(tab,v) if #v:GetChildren() > 0 then Scan(v,tab) end end end return tab end parts = Scan( Workspace.Model ) -- Edit 'Workspace.Model' with your terrain for _,v in pairs(parts) do v.BrickColor = BrickColor.Green() -- Edit the parts v.Transparency = 0 --etc end
Here is where I got info from.. http://wiki.roblox.com/index.php?title=API:Instance/GetChildren
Anyways, according to that, if you read it there is a script..
local children = Workspace:GetChildren() -- edit this for i = 1, #children do print(children[i].Name) -- edit this end
All you need to do is change it to include the model Workspace.(ModelName):GetChildren()
then delete print and put what you want to edit about them inside there.
I believe this should work, but I can't be 100% sure on it because i've never used it yet.