Skip to main content

Conversions

Converts between Sounds and SoundDefinitions. These do not need the schema, so they work before startup.

Functions​

ToDefinition​

Conversions.ToDefinition(
sound: Sound--

The Sound to convert.

) → SoundDefinition--

The definition.

Turns a Sound and its SoundEffect children into a SoundDefinition. Only properties that differ from the defaults are kept, plus the name.

local definition = VluxySF.Conversions.ToDefinition(workspace.MySound)

print(definition.Properties.Volume)

FromDefinition​

Conversions.FromDefinition(
definition: SoundDefinition--

The definition to build.

) → Sound--

The new Sound.

Builds a new, unparented Sound from a SoundDefinition. Effects are parented under their class names.

local sound = VluxySF.Conversions.FromDefinition({
	Properties = {
		Name = "MySound",
		SoundId = "rbxassetid://123456789",
		Volume = 0.5,
	},
	Effects = {
		EchoSoundEffect = { Delay = 0.5 },
	},
	EffectsCount = 1,
})

sound.Parent = workspace
sound:Play()
Show raw api
{
    "functions": [
        {
            "name": "ToDefinition",
            "desc": "Turns a `Sound` and its `SoundEffect` children into a `SoundDefinition`. Only properties that differ from the\ndefaults are kept, plus the name.\n\n```lua\nlocal definition = VluxySF.Conversions.ToDefinition(workspace.MySound)\n\nprint(definition.Properties.Volume)\n```",
            "params": [
                {
                    "name": "sound",
                    "desc": "The `Sound` to convert.",
                    "lua_type": "Sound"
                }
            ],
            "returns": [
                {
                    "desc": "The definition.",
                    "lua_type": "SoundDefinition"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 30,
                "path": "lib/Api/Conversions.luau"
            }
        },
        {
            "name": "FromDefinition",
            "desc": "Builds a new, unparented `Sound` from a `SoundDefinition`. Effects are parented under their class names.\n\n```lua\nlocal sound = VluxySF.Conversions.FromDefinition({\n\tProperties = {\n\t\tName = \"MySound\",\n\t\tSoundId = \"rbxassetid://123456789\",\n\t\tVolume = 0.5,\n\t},\n\tEffects = {\n\t\tEchoSoundEffect = { Delay = 0.5 },\n\t},\n\tEffectsCount = 1,\n})\n\nsound.Parent = workspace\nsound:Play()\n```",
            "params": [
                {
                    "name": "definition",
                    "desc": "The definition to build.",
                    "lua_type": "SoundDefinition"
                }
            ],
            "returns": [
                {
                    "desc": "The new `Sound`.",
                    "lua_type": "Sound"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 60,
                "path": "lib/Api/Conversions.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Conversions",
    "desc": "Converts between `Sounds` and `SoundDefinitions`. These do not need the schema, so they work before startup.",
    "source": {
        "line": 12,
        "path": "lib/Api/Conversions.luau"
    }
}