Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to select ALL parts within a model?

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

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.