Skip to main content

AssetInsertManager

Handles the loading of assets on the server and client. This is useful for preloading assets on the server and then using them on the client.

Functions

Preload

This item only works when running on the server. Server
AssetInsertManager:Preload(...(number | string)) → {Promise}--

An array of promises resolving with each asset. Can be used in conjunction with Promise.all, Promise.any, etc...

Takes a varargs list of assetIds and preloads them on the server.

local proms = AssetInsertManager:Preload(123456789, 987654321)

Promise.all(proms)
:andThenCall(print, "All assets loaded successfully")

PromiseAsset

AssetInsertManager:PromiseAsset(assetIdnumber | string) → Promise

Promises a copy of the requested asset. If this is called on the server and the asset is not loaded, it will be preloaded.

AssetInsertManager:PromiseAsset(123456789):andThen(function(asset)
	-- do something with the asset copy
end)

AssetIsLoaded

AssetInsertManager:AssetIsLoaded(assetIdnumber | string) → boolean

Checks if an asset is loaded.

GetAsset

AssetInsertManager:GetAsset(assetIdnumber | string) → Instance?

Gets a copy of an asset by its assetId if it is loaded.

ClearLoadedAssets

This item only works when running on the server. Server
AssetInsertManager:ClearLoadedAssets() → ()

Clears all loaded assets.

Show raw api
{
    "functions": [
        {
            "name": "Preload",
            "desc": "Takes a varargs list of assetIds and preloads them on the server.\n\n```lua\nlocal proms = AssetInsertManager:Preload(123456789, 987654321)\n\nPromise.all(proms)\n:andThenCall(print, \"All assets loaded successfully\")\n```",
            "params": [
                {
                    "name": "...",
                    "desc": "",
                    "lua_type": "(number | string)"
                }
            ],
            "returns": [
                {
                    "desc": "An array of promises resolving with each asset. Can be used in conjunction with Promise.all, Promise.any, etc...",
                    "lua_type": "{Promise}"
                }
            ],
            "function_type": "method",
            "realm": [
                "Server"
            ],
            "source": {
                "line": 72,
                "path": "src/assetinsertmanager/src/AssetInsertManager.lua"
            }
        },
        {
            "name": "PromiseAsset",
            "desc": "Promises a copy of the requested asset. If this is called on the server and the asset is not loaded, it will be preloaded.\n```lua\nAssetInsertManager:PromiseAsset(123456789):andThen(function(asset)\n\t-- do something with the asset copy\nend)\n```",
            "params": [
                {
                    "name": "assetId",
                    "desc": "",
                    "lua_type": "number | string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 124,
                "path": "src/assetinsertmanager/src/AssetInsertManager.lua"
            }
        },
        {
            "name": "AssetIsLoaded",
            "desc": "Checks if an asset is loaded.",
            "params": [
                {
                    "name": "assetId",
                    "desc": "",
                    "lua_type": "number | string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 151,
                "path": "src/assetinsertmanager/src/AssetInsertManager.lua"
            }
        },
        {
            "name": "GetAsset",
            "desc": "Gets a copy of an asset by its assetId if it is loaded.",
            "params": [
                {
                    "name": "assetId",
                    "desc": "",
                    "lua_type": "number | string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Instance?\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 160,
                "path": "src/assetinsertmanager/src/AssetInsertManager.lua"
            }
        },
        {
            "name": "ClearLoadedAssets",
            "desc": "Clears all loaded assets.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "realm": [
                "Server"
            ],
            "source": {
                "line": 170,
                "path": "src/assetinsertmanager/src/AssetInsertManager.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "AssetInsertManager",
    "desc": "Handles the loading of assets on the server and client.\nThis is useful for preloading assets on the server and then using them on the client.",
    "source": {
        "line": 9,
        "path": "src/assetinsertmanager/src/AssetInsertManager.lua"
    }
}