Skip to main content

Jitter

Builders for small random variations, meant for the Volume and PlaybackSpeed of sounds so repeated sounds do not sound identical. Each builder returns a function that gives a new value every time it is called.

INFO

Values never go below 0, since a negative volume or speed means nothing. There is no upper clamp; Roblox clamps the property itself.

A builder never throws. An argument that is not a number warns when the builder is called and falls back to a value that gives no variation, so the mistake shows up where it was made and the sounds keep playing.

Functions​

Uniform​

Jitter.Uniform(
center: number,--

The value the jitter varies around. Falls back to 1 when it is not a number.

spread: number--

The largest distance from the center. Falls back to 0 when it is not a number.

) → () → number--

Gives a new value when called.

Spreads values evenly between center - spread and center + spread.

local speed = VluxySF.Jitter.Uniform(1, 0.15)

sound1.PlaybackSpeed = speed() -- a random value from 0.85 to 1.15
sound2.PlaybackSpeed = speed() -- another one

Range​

Jitter.Range(
min: number,--

The smallest value. Falls back to max when it is not a number.

max: number--

The largest value. Falls back to min when it is not a number.

) → () → number--

Gives a new value when called.

Spreads values evenly between min and max. When min is above max the two are swapped.

local speed = VluxySF.Jitter.Range(0.85, 1.15)

sound.PlaybackSpeed = speed()

Natural​

Jitter.Natural(
center: number,--

The value the jitter varies around. Falls back to 1 when it is not a number.

spread: number--

The largest distance from the center. Falls back to 0 when it is not a number.

) → () → number--

Gives a new value when called.

Like Uniform, but values cluster near the center and rarely reach the edges, which sounds more natural for repeated sounds like footsteps.

local volume = VluxySF.Jitter.Natural(0.8, 0.1)

footstep.Volume = volume()
Show raw api
{
    "functions": [
        {
            "name": "Uniform",
            "desc": "Spreads values evenly between `center - spread` and `center + spread`.\n\n```lua\nlocal speed = VluxySF.Jitter.Uniform(1, 0.15)\n\nsound1.PlaybackSpeed = speed() -- a random value from 0.85 to 1.15\nsound2.PlaybackSpeed = speed() -- another one\n```",
            "params": [
                {
                    "name": "center",
                    "desc": "The value the jitter varies around. Falls back to 1 when it is not a number.",
                    "lua_type": "number"
                },
                {
                    "name": "spread",
                    "desc": "The largest distance from the center. Falls back to 0 when it is not a number.",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "Gives a new value when called.",
                    "lua_type": "() -> number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 61,
                "path": "lib/Api/Jitter.luau"
            }
        },
        {
            "name": "Range",
            "desc": "Spreads values evenly between `min` and `max`. When `min` is above `max` the two are swapped.\n\n```lua\nlocal speed = VluxySF.Jitter.Range(0.85, 1.15)\n\nsound.PlaybackSpeed = speed()\n```",
            "params": [
                {
                    "name": "min",
                    "desc": "The smallest value. Falls back to `max` when it is not a number.",
                    "lua_type": "number"
                },
                {
                    "name": "max",
                    "desc": "The largest value. Falls back to `min` when it is not a number.",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "Gives a new value when called.",
                    "lua_type": "() -> number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 86,
                "path": "lib/Api/Jitter.luau"
            }
        },
        {
            "name": "Natural",
            "desc": "Like `Uniform`, but values cluster near the center and rarely reach the edges, which sounds more natural for\nrepeated sounds like footsteps.\n\n```lua\nlocal volume = VluxySF.Jitter.Natural(0.8, 0.1)\n\nfootstep.Volume = volume()\n```",
            "params": [
                {
                    "name": "center",
                    "desc": "The value the jitter varies around. Falls back to 1 when it is not a number.",
                    "lua_type": "number"
                },
                {
                    "name": "spread",
                    "desc": "The largest distance from the center. Falls back to 0 when it is not a number.",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "Gives a new value when called.",
                    "lua_type": "() -> number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 118,
                "path": "lib/Api/Jitter.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Jitter",
    "desc": "Builders for small random variations, meant for the `Volume` and `PlaybackSpeed` of sounds so repeated sounds do not\nsound identical. Each builder returns a function that gives a new value every time it is called.\n\n:::info\nValues never go below 0, since a negative volume or speed means nothing. There is no upper clamp; Roblox clamps the\nproperty itself.\n\nA builder never throws. An argument that is not a number warns when the builder is called and falls back to a value\nthat gives no variation, so the mistake shows up where it was made and the sounds keep playing.\n:::",
    "source": {
        "line": 42,
        "path": "lib/Api/Jitter.luau"
    }
}