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

How do I get the children of a model's children?

Asked by
OniiCh_n 410 Moderation Voter
10 years ago

So I have a 10k part model generated through an OBJ importer. The children of said model have mesh that makes each part uber thin. This creates an illusion of the player floating over the actual part. (Hard to put into words, just witness it for yourself here: http://www.roblox.com/Overrun-place?id=155627099)

Anyways, I discovered that deleting the mesh returns the model to its correct size and eliminates the crappy illusion. Now, since there are 10k parts: I DON'T WANNA OPEN UP EACH ONE IN THE EXPLORER AND DELETE THE MESH.

It would take me OVER 9000 years to do.

So how would I get the children of the children of a model and delete each child?

Here's the hierarchy:

Model > 10k Parts Each individual part > Mesh

How do I delete that mesh?

2 answers

Log in to vote
1
Answered by
Sublimus 992 Moderation Voter
10 years ago

Use a for loop and delete each mesh:

for _, v in pairs(game.Workspace.Model:getChildren()) do -- This gets all of the children and places them in a table, and then loops through each child
wait() -- Just a little safeguard to avoid crashing
    if v.ClassName == "Part" and v:findFirstChild("Mesh") then -- Check if object is a part and has a mesh
        v.Mesh:Destroy() -- Destroy the mesh
    end -- End if statement
end -- End loop
Ad
Log in to vote
1
Answered by
HexC3D 830 Moderation Voter
10 years ago
z = game.Model:GetChildren()
for i = 1,#z do
z[i]:FindFirstChild("Mesh"):Destroy()
wait()
end

That should destroy the mesh's

Plus 1 if this helped , check mark if this answered your query :)

0
It would be nice if you annotated your code, just putting it there doesn't help them understand it. Sublimus 992 — 10y
0
Mk. HexC3D 830 — 10y

Answer this question