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

Can scripts un-group models?

Asked by 9 years ago

I was wondering if scripts can un-group models in workspace or lighting.

2 answers

Log in to vote
0
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
9 years ago

You could find and clone all the descendants of the model, delete the model, then set the parent of the cloned descendants to the place it should be. I'm not aware of any API to directly do this though.

Ad
Log in to vote
0
Answered by 9 years ago

Yes, but there is no function for it. Here is an example of it.

Model = Workspace.SampleModel -- Find the model
ModelParent = Model.Parent -- Find the parent of the model

for i, v in pairs(Model:GetChildren()) do -- Parent all the children of the model to the parent of the model
    v.Parent = ModelParent
end
Model:remove() -- Remove the model

This script is very simple and I believe that it would work considering the hierarchy is correct.

Answer this question