So I want to get all parts inside workspace from a script. Like every BasePart or something.
1 Like
local base_parts = { }
for _, descendant in ipairs(workspace:GetDescendants()) do
if descendant:IsA("BasePart") then
table.insert(base_parts, descendant)
end
end
not much to say.
2 Likes
But what if they’re inside a model?
If you only want it to get every part on the first layer of the Workspace, you can call :GetChildren()
on the Workspace – if you want to access every part regardless if it’s inside of a folder, model, etc., you can call :GetDescendants()
on the Workspace instead.
More info about these can be found from the following resources:
That is why I used :GetDescendants
@sjr04 Will still work as GetDescendants will also check the children of the of the children of workspace and so on
Oh okay, I did not know I could use :GetDescendants