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

Ungroup script for InsertService?

Asked by 8 years ago
local assetId=47637
game:GetService("InsertService"):LoadAsset(assetId).Parent=scparent.Backpack

This creates a model in the player's Backpack, how could I ungroup it using code?

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
8 years ago

Essentials

What you're trying to do requires simply parenting the inserted model to your wanted location, iterating through said model, and parenting all of it's childern to the model's parent. Afterwards you can just delete the inserted model.


Code

local insert = game:GetService("InsertService")
local assetId 

function unGroup(model)
    for _,v in next,model:GetChildren() do
        v.Parent = model.Parent
    end
    model:Destroy()
end

local model = insert:LoadAsset(assetId)
model.Parent = scparent.Backpack

unGroup(model)
Ad

Answer this question