AssetService
Download any Roblox asset by id, save it as the file it really is, load a Model's instances, and upload new images, sounds and Models.
Downloads ask Roblox with Roblox Studio's sign-in on this computer, then fetch the file itself with no cookie; SaveAsync and LoadModelAsync read through the AssetCache, so a second read makes no request. Uploads go through OpenCloudService and give an AssetUpload that follows Roblox's processing by itself. Busy and server errors are retried; any other failure comes back as nil and a why naming the asset.
A service: write use AssetService.
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| Cache | AssetCache | read-only | The AssetCache that SaveAsync and LoadModelAsync read through; GetAssetBytesAsync never uses it. |
| DeliveryBaseUrl | string | "https://assetdelivery.roblox.com" | Where downloads ask for an asset's location, the only address that gets Roblox Studio's sign-in; the file itself is fetched with no cookie. |
| InfoBaseUrl | string | "https://economy.roblox.com" | Where GetAssetInfoAsync asks for an asset's details; that request is public and carries no cookie. |
Methods
| Name | Arguments | Returns | Description |
|---|---|---|---|
| GetAssetBytesAsync yields | (assetId: number) | (buffer?, string?) | Waits for the asset's file as Roblox serves it now, never cached; 429 and 5xx are retried, other failures give nil and why. |
| GetAssetInfoAsync yields | (assetId: number) | (AssetInfo?, string?) | Waits for the asset's type, name, description, creator and last update, in seconds since 1970; an unknown id gives nil and why. |
| SaveAsync yields | (assetId: number, path: string) | (boolean, string?) | Saves the asset through Cache; the path's ending must match the bytes (.png, .ogg, .rbxm, .mesh), and a Decal saved as .png gets its image. |
| LoadModelAsync yields | (assetId: number) | ({ RobloxInstance }?, string?) | Waits for a Model asset's top-level instances, read through Cache; they are yours to parent, and no PlaceFile is left open. |
| ParseId | (text: string | number) | number? | The asset id in rbxassetid://123, an asset address, "123" or 123; nil when there is none or two different ones. |
| UploadAssetAsync yields | (path: string, assetType: "Image" | "Decal" | "Audio" | "Model", options: UploadOptions?) | (AssetUpload?, string?) | Returns once Roblox has the file as a new asset; the AssetUpload then follows processing by itself, and a .wav goes up as .ogg. |
| UploadVersionAsync yields | (assetId: number, path: string, options: UploadOptions?) | (AssetUpload?, string?) | Uploads a file as a new version of an existing asset, its type taken from the file's ending, and returns once Roblox has the file. |
From ShotInstance 33
ClassNameNameParentAncestryChangedAttributeChangedChangedChildAddedChildRemovedDestroyingAddTagClearAllChildrenCloneDestroyFindFirstAncestorFindFirstAncestorOfClassFindFirstAncestorWhichIsAFindFirstChildFindFirstChildOfClassFindFirstChildWhichIsAGetAttributeGetAttributeChangedSignalGetAttributesGetChildrenGetDescendantsGetFullNameGetPropertyChangedSignalGetTagsHasTagIsAIsAncestorOfIsDescendantOfRemoveTagSetAttribute
