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

How to upload a package?

So i've been looking through the wiki, and i found AssetService. I've been trying to use GetAssetIdsForPackage but it won't work. Example:

game:GetService("AssetService"):GetAssetIdsForPackage(193700907)

It doesn't seem to work. Am i doing something wrong here

2 answers

✓ Accepted answer

AssetService:GetAssetIdsForPackage() returns an array of int64 values (asset IDs), so you'll need to insert all of the IDs returned from the function.

function insertpackage(id,parent)
       local IDs = game:GetService('AssetService'):GetAssetIdsForPackage(id)
       for _, v in pairs(IDs) do
              game:GetService('InsertService'):LoadAsset(v):GetChildren()[1].Parent=parent
       end
end

insertpackage(193700907, workspace)

Try running the following code in the command bar in Studio.

for _, id in pairs(game:GetService("AssetService"):GetAssetIdsForPackage(193700907)) do
    local model = game:GetService("InsertService"):LoadAsset(id).Parent
    model.Name = tostring(id)
    model.Parent = game.Workspace
end

2 comments

0

huh? it says "3:attempt to index local 'model' (a nil value)"

0

Pretty much because he attempted to access the parent of inserted asset, when the parent is set to nil

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