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

How to upload a package?

Asked by 6 years ago

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

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
6 years ago

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)
Ad
Log in to vote
1
Answered by 6 years ago

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
0
huh? it says "3:attempt to index local 'model' (a nil value)" GamingOverlord756 48 — 6y
0
Pretty much because he attempted to access the parent of inserted asset, when the parent is set to nil Rare_tendo 3000 — 6y

Answer this question