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

How to select ALL parts within a model?

Asked by 9 years ago

So, is it possible to have a script to select all parts within a model? I want to do this so I can make it rotate. It would also be great if there was an "exception" list, meaning some parts do not move.

I had this script a while a go, which recolours everything within the workspace. I'm pretty sure it's something to do with pairs or something.

local s,o,b = {workspace},BrickColor.new('Deep orange'),BrickColor.new('Really blue');
while s[1] do
local a = table.remove(s,1);
for _,v in ipairs(a:GetChildren()) do
table.insert(s,v);
end
if a:IsA('Part') and a.BrickColor == o then a.BrickColor = b end
end

Thanks

1 answer

Log in to vote
0
Answered by 9 years ago

This code will allow you to get all of the parts, and then put then in a table

function FindChildren(Where)
local S = {}
for _,n in pairs(Where:GetChildren()) do
S[#S+1] = n
wait()
FindChildren(n)
end
return S
end

Any questions, let me know

Ad

Answer this question