Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I change the properties of an entire model?

Asked by
OniiCh_n 410 Moderation Voter
10 years ago

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.

0
According to roblox and the answers below, you will have to use GetChildren Tesouro 407 — 10y

3 answers

Log in to vote
-1
Answered by 10 years ago

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 ._.

0
You are wrong dear sir. omeybabyface 140 — 10y
0
I just re-tested it and it works sir. >.< TochiWasHere 10 — 10y
0
Instead of 'if part:IsA("Part") or part:IsA("WedgePart") or part:IsA("CornerWedgePart") then' you could just check if the the part is a BasePart (if part:IsA("BasePart")). coo1o 227 — 10y
0
I left it in a model. Who leaves that amount of parts in Workspace?!?! OniiCh_n 410 — 10y
0
Thanks coo1o! :D TochiWasHere 10 — 10y
Ad
Log in to vote
1
Answered by
hiccup111 231 Moderation Voter
10 years ago


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
0
NOTE, this may take time, or lag, depending on how good your PC is. hiccup111 231 — 10y
Log in to vote
0
Answered by
lomo0987 250 Moderation Voter
10 years ago

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.

Answer this question