Skip to main content

SoundUtils

Helps plays back sounds in the Roblox engine.

SoundUtils.playFromId("rbxassetid://4255432837") -- Plays a wooshing sound

Functions

playFromId

SoundUtils.playFromId(idstring | number | table) → Sound

Plays back a template given asset id.

SoundUtils.playFromId("rbxassetid://4255432837") -- Plays a wooshing sound
tip

The sound will be automatically cleaned up after the sound is played.

createSoundFromId

SoundUtils.createSoundFromId(idstring | number | table) → Sound

Creates a new sound object from the given id

playFromIdInParent

SoundUtils.playFromIdInParent(
idstring | number | table,
parentInstance
) → Sound

Plays back a template given asset id in the parent

removeAfterTimeLength

SoundUtils.removeAfterTimeLength(soundSound) → ()

Loads the sound and then cleans up the sound after load.

playTemplate

SoundUtils.playTemplate(
templatesTemplateProvider,
templateNamestring
) → Sound

Plays back a template given the templateName.

tip

The sound will be automatically cleaned up after the sound is played.

toRbxAssetId

SoundUtils.toRbxAssetId(idstring? | number) → string?

Converts a string or number to a string for playback.

playTemplateInParent

SoundUtils.playTemplateInParent(
templatesTemplateProvider,
templateNamestring,
parentInstance
) → Sound

Plays back a sound template in a specific parent.

tip

The sound will be automatically cleaned up after the sound is played.

Show raw api
{
    "functions": [
        {
            "name": "playFromId",
            "desc": "Plays back a template given asset id.\n\n```lua\nSoundUtils.playFromId(\"rbxassetid://4255432837\") -- Plays a wooshing sound\n```\n\n:::tip\nThe sound will be automatically cleaned up after the sound is played.\n:::",
            "params": [
                {
                    "name": "id",
                    "desc": "",
                    "lua_type": "string | number | table"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Sound"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 34,
                "path": "src/sounds/src/Shared/SoundUtils.lua"
            }
        },
        {
            "name": "createSoundFromId",
            "desc": "Creates a new sound object from the given id",
            "params": [
                {
                    "name": "id",
                    "desc": "",
                    "lua_type": "string | number | table"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Sound\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 51,
                "path": "src/sounds/src/Shared/SoundUtils.lua"
            }
        },
        {
            "name": "playFromIdInParent",
            "desc": "Plays back a template given asset id in the parent",
            "params": [
                {
                    "name": "id",
                    "desc": "",
                    "lua_type": "string | number | table"
                },
                {
                    "name": "parent",
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Sound\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 90,
                "path": "src/sounds/src/Shared/SoundUtils.lua"
            }
        },
        {
            "name": "removeAfterTimeLength",
            "desc": "Loads the sound and then cleans up the sound after load.",
            "params": [
                {
                    "name": "sound",
                    "desc": "",
                    "lua_type": "Sound"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 108,
                "path": "src/sounds/src/Shared/SoundUtils.lua"
            }
        },
        {
            "name": "playTemplate",
            "desc": "Plays back a template given the templateName.\n\n:::tip\nThe sound will be automatically cleaned up after the sound is played.\n:::",
            "params": [
                {
                    "name": "templates",
                    "desc": "",
                    "lua_type": "TemplateProvider"
                },
                {
                    "name": "templateName",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Sound"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 130,
                "path": "src/sounds/src/Shared/SoundUtils.lua"
            }
        },
        {
            "name": "toRbxAssetId",
            "desc": "Converts a string or number to a string for playback.",
            "params": [
                {
                    "name": "id",
                    "desc": "",
                    "lua_type": "string? | number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 152,
                "path": "src/sounds/src/Shared/SoundUtils.lua"
            }
        },
        {
            "name": "playTemplateInParent",
            "desc": "Plays back a sound template in a specific parent.\n\n:::tip\nThe sound will be automatically cleaned up after the sound is played.\n:::",
            "params": [
                {
                    "name": "templates",
                    "desc": "",
                    "lua_type": "TemplateProvider"
                },
                {
                    "name": "templateName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "parent",
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Sound"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 180,
                "path": "src/sounds/src/Shared/SoundUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "SoundUtils",
    "desc": "Helps plays back sounds in the Roblox engine.\n\n```lua\nSoundUtils.playFromId(\"rbxassetid://4255432837\") -- Plays a wooshing sound\n```",
    "source": {
        "line": 10,
        "path": "src/sounds/src/Shared/SoundUtils.lua"
    }
}