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

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

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

✓ Accepted answer

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
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 :)

2 comments

0

It would be nice if you annotated your code, just putting it there doesn't help them understand it.

0

Mk.

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