Skip to main content

Preload

This item only works when running on the client. ClientRequiresSchema

Preloading downloads a sound's audio ahead of time and keeps it loaded for the whole session, so the sound plays without a delay the first time it is needed.

Sounds tagged VluxySF_Preload in Studio are preloaded by Startup.InitClient. Use AddAsync to preload more at runtime. This is about the network; to keep built Sound instances ready instead, see Cache.

Called on the server or before the library has started, every function here warns once and does nothing.

Functions​

AddAsync​

This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. Yields
Preload.AddAsync(
...: string--

The sound names.

) → ()

Preloads more sounds by name and yields until their audio has loaded. A name that is already preloaded is skipped, and a name that is not in the schema prints a warning.

VluxySF.Preload.AddAsync("BossRoar", "BossStomp")

Has​

Preload.Has(
name: string--

The sound name.

) → boolean--

Whether the sound is preloaded, or being preloaded.

print(VluxySF.Preload.Has("BossRoar"))

GetNames​

Preload.GetNames() → {string}--

A new array of every preloaded sound name, sorted.

print(VluxySF.Preload.GetNames())
Show raw api
{
    "functions": [
        {
            "name": "AddAsync",
            "desc": "Preloads more sounds by name and yields until their audio has loaded. A name that is already preloaded is skipped,\nand a name that is not in the schema prints a warning.\n\n```lua\nVluxySF.Preload.AddAsync(\"BossRoar\", \"BossStomp\")\n```",
            "params": [
                {
                    "name": "...",
                    "desc": "The sound names.",
                    "lua_type": "string"
                }
            ],
            "returns": [],
            "function_type": "static",
            "yields": true,
            "source": {
                "line": 39,
                "path": "lib/Api/Preload.luau"
            }
        },
        {
            "name": "Has",
            "desc": "```lua\nprint(VluxySF.Preload.Has(\"BossRoar\"))\n```",
            "params": [
                {
                    "name": "name",
                    "desc": "The sound name.",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "Whether the sound is preloaded, or being preloaded.",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 59,
                "path": "lib/Api/Preload.luau"
            }
        },
        {
            "name": "GetNames",
            "desc": "```lua\nprint(VluxySF.Preload.GetNames())\n```",
            "params": [],
            "returns": [
                {
                    "desc": "A new array of every preloaded sound name, sorted.",
                    "lua_type": "{ string }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 76,
                "path": "lib/Api/Preload.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Preload",
    "desc": "Preloading downloads a sound's audio ahead of time and keeps it loaded for the whole session, so the sound plays\nwithout a delay the first time it is needed.\n\nSounds tagged `VluxySF_Preload` in Studio are preloaded by `Startup.InitClient`. Use `AddAsync` to preload more at\nruntime. This is about the network; to keep built `Sound` instances ready instead, see `Cache`.\n\nCalled on the server or before the library has started, every function here warns once and does nothing.",
    "tags": [
        "RequiresSchema"
    ],
    "realm": [
        "Client"
    ],
    "source": {
        "line": 23,
        "path": "lib/Api/Preload.luau"
    }
}