AssetService

Show Deprecated
Not Creatable
Service

The AssetService is a non-replicated service that handles asset related queries to the Roblox web API. Eventually, this will house all asset related queries for Roblox objects stored in the web. One should mind the limitations this API has.

Summary

Properties

Events

Methods

CreatePlaceAsync(placeName: string, templatePlaceID: number, description: string): number  YIELDS

Clones a place with placeId equal to given templatePlaceId.

CreatePlaceInPlayerInventoryAsync(player: Instance, placeName: string, templatePlaceID: number, description: string): number  YIELDS

Clones a place which has placeId equal to given templatePlaceId and puts it into the inventory of the given player.

GetAssetIdsForPackage(packageAssetId: number): Array  YIELDS

Returns an array of assetIds that are contained in a specified package.

GetAssetThumbnailAsync(assetId: number, thumbnailSize: Vector2, assetType: number): Tuple  YIELDS


GetBundleDetailsAsync(bundleId: number): table  YIELDS

Returns details of the contents of specified bundle.


Returns a StandardPages object which contains the name and placeId of places within the current 'Game' (otherwise known as a 'Universe').

SavePlaceAsync(): void  YIELDS

Saves the state of the current place.

Properties

Events

Methods

GetBundleDetailsSync

Roblox Script Security

Parameters

bundleId: number

Returns

CreatePlaceAsync

Yields

Clones a place with placeId equal to given templatePlaceId. The clone place displays within the inventory of the place's creator with the given name and description. This method returns the placeId of the new place, which you can use with TeleportService. The template place must have template copying enabled through place settings. You cannot use this method to clone places that you don't own.

Frequent use of this API isn't recommended, particularly if the created places contain scripts, as updating the code in a large volume of places quickly becomes infeasible. For user-generated worlds, consider serializing user creations and saving them in DataStores instead.

Parameters

placeName: string
templatePlaceID: number
description: string
Default Value: ""

Returns

CreatePlaceInPlayerInventoryAsync

Yields

This function has been removed as of Release 471. Clones a place which has a placeId equal to the given templatePlaceID, placing it into the inventory of the given player with the given name and description, if they accept when prompted. This method cannot be used to clone places that you do not own, or those which have disabled the use of the CreatePlace API in their place's configuration.

Parameters

player: Instance
placeName: string
templatePlaceID: number
description: string
Default Value: ""

Returns

GetAssetIdsForPackage

Yields

Returns an array of assetIds that are contained in a specified package.

Parameters

packageAssetId: number

Returns

GetAssetThumbnailAsync

Yields
Roblox Script Security

Parameters

assetId: number
thumbnailSize: Vector2
assetType: number
Default Value: "0"

Returns

GetBundleDetailsAsync

Yields

If the bundle Id does not exist, it throws HTTP 400 (HTTP/1.1 400 Bad Request). If bundleId is not convertible to int, throws "Unable to cast string to int64". If param type is string, it implicitly tries to convert to int.

This function returns details of the contents of the specified bundle.

Understanding the returned ValueTable

It returns a ValueTable object with the following key-value pairs containing details about the specified bundle

Key NameValue TypeDescription
Id numberintBundle Id (passed in as an argument)
NamestringBundle name
DescriptionstringBundle description
BundleTypestringBundle Type. eg. BodyParts or `AvatarAnimation|AvatarAnimations`
ItemsValueArrayAn array of ValueTable objects

Each object in the Items array contains details of the item as described in the table below:

Key NameValue TypeDescription
Id numberintItem's id
NamestringItem name
TypestringItem Type eg: "UserOutfit" or "Asset"

Parameters

bundleId: number

The id of the specified bundle.


Returns

A ValueTable object with the following key-value pairs containing details about the specified bundle. See the function description for more information.

Code Samples

Getting Bundle Details

1local AssetService = game:GetService("AssetService")
2
3local BUNDLE_ID = 13
4
5local bundleDetails = AssetService:GetBundleDetailsAsync(BUNDLE_ID)
6
7print(bundleDetails)

GetGamePlacesAsync

Yields

Returns a StandardPages object which contains the name and placeId of places within the current 'Game' (otherwise known as a 'Universe').


Returns

Code Samples

AssetService:GetGamePlacesAsync

1local AssetService = game:GetService("AssetService")
2
3local pages = AssetService:GetGamePlacesAsync()
4
5while true do
6 for _, place in pairs(pages:GetCurrentPage()) do
7 print("Name: " .. place.Name)
8 print("PlaceId: " .. tostring(place.PlaceId))
9 end
10 if pages.IsFinished then
11 -- we reached the last page of results
12 break
13 end
14 pages:AdvanceToNextPageAsync()
15end

SavePlaceAsync

void
Yields

Saves the state of the current place. This only works for places that are created with AssetService:CreatePlaceAsync() or have the API enabled through place settings.


Returns

void