Hey, I've been trying to remove a child from a parent, but for some reason this doesn't execute, yet no errors lie in the output.
while wait() do
index = 0
for index, child in pairs(workspace:FindFirstChild("20PercentBrickMesh"):GetChildren()) do
if child.Name == "Mesh" then child:Destroy()
print("Removed:" .. index .. child)
index = index + 1
end
end
end
My objective here was to grab all the 20PercentBrickMeshes, and delete the Meshes inside of them, as they lag up the server. The setup in the Hierarchy of the parts are:
game-> Workspace -> 20PercentBrickMesh -> Mesh
I'm not sure what's wrong.

1 comment
You should just use i instead of index since i is automatically a local variable and will update and also instead of child.Name == "Mesh" do child:IsA("Mesh"). You're also destroying the child so print is receiving a nil value. If that doesn't work then provide