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

I don't know how to find all the children from all the models in the game. Any help ?

Asked by
InLeXiX 18
4 years ago
Edited 4 years ago
local RenderParts = {}
for i,v in pairs(game.Workspace:GetChildren()) do
    if v.ClassName == "Part" then
        table.insert(RenderParts, v)
    elseif v.ClassName == "Model" then
        table.insert(RenderParts, v.ClassName("Model"):GetChildren())
    end
end

PlayerScripts.Render:6: attempt to call a string value

0
You would have to do another for loop for that model to insert each child. so it would be else if ..... for _,_ in pairs(model:GetChildren()) do insert end killerbrenden 1537 — 4y

1 answer

Log in to vote
0
Answered by
xAtom_ik 574 Moderation Voter
4 years ago
Edited 4 years ago

Use :GetDescendants() instead of :GetChildren() to get every instance in the Workspace, instead of just the direct children.

Edit: Using GetDescendants, you can remove the part where it checks for the Model as it is not needed.

Ad

Answer this question