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

InsertService Question

Well, I know that you can do this:

game:GetService("InsertService"):LoadAsset(--asset).Parent = Workspace

But, when I change the parent part to game.Players.Greatgreatgood5.Backpack, it always ends up as a model. Help?

2 answers

✓ Accepted answer

When you call LoadAsset, all of the parts are grouped into a Model. This is because the asset might contain multiple instances.

You can select the first object inside the model as follows:

game:GetService("InsertService"):LoadAsset(assetId):GetChildren()[1].Parent = Workspace

GetChildren returns a table of the model's children, so GetChildren()[1] gives you the first object in the table.

1 comment

0

Thanks, Merely!

The LoadAsset method always puts whatever it loads in a model object. This is because models on ROBLOX can contain many objects at their root, so the LoadAsset method would need to return many things in cases where it loaded many objects if it didn’t put them in a model object.

You can iterate through all the children of the model returned by the LoadAsset method to put them all where you want them to be:

for _, child in next, Game:GetService('InsertService'):LoadAsset(--[[asset]]):GetChildren() do
    child.Parent = Game:GetService('Players').Greatgreatgood5.Backpack
end

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