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

Is there a way for one to ungroup a model via a script?

Asked by 5 years ago

When editing in studio you can group and ungroup objects/assets you've created. Is there a way you can ungroup or group an object through a script. I know you can use a loop to access the objects inside the group and change their parent, the delete the group itself. However is there a simple command to do this?

0
Nope you have to code it. User#5423 17 — 5y

2 answers

Log in to vote
1
Answered by 5 years ago

This is actually really simple:

local model = script.Parent.Model
local children = model:GetChildren()
for _,i in pairs(children) do
    i.Parent = workspace
end

All you have to do is run a for loop through the children of the model and make all of their parents the Workspace.

0
Didn't I already say that? Hmm... Stephenthefox 94 — 5y
0
it's the simplest way to do it DeceptiveCaster 3761 — 5y
Ad
Log in to vote
0
Answered by 3 years ago
local model = Instance.new('Model', game.Workspace)
model.Name = 'Model'
local parta = script.Parent.PartA
local partb = script.Parent.PartB
parta.Parent = model
partb.Parent = model

Simple and Easy

Answer this question