Skip to main content

PlayerNoise

Players make noise by moving. Give it the noise signal your Hearing senses listen to and the speed bands; while a player moves at a band's speed or faster, a noise of that band is fired at their feet every Every seconds, with their character as the source. Standing still, or moving below the slowest band, is silent.

local function step(loudness)
	return function(_speed, character)
		return if character:GetAttribute("Crouching") then nil else loudness
	end
end

VluxyAI.PlayerNoise.new(noises, {
	{ Speed = 4, Every = 0.7, Loudness = step(0.25), Kind = "Footstep" }, -- walking, silent crouched
	{ Speed = 19, Every = 0.5, Loudness = 0.6, Kind = "Running" },        -- sprinting
})

Types​

NoiseBand​

interface NoiseBand {
Speed: number--

Studs per second at or above which this band applies. The fastest band a player reaches wins.

Every: number--

Seconds between noises while in this band.

Loudness: number | (
speed: number,
character: Model
) → number?--

Passed to the signal; a Hearing with Range hears it from Range * Loudness studs. A function is asked on every noise; nil or 0 makes none (a crouch off an attribute).

Kind: string?--

Passed as the third argument, written as HeardKind by Hearing.

}

Functions​

Band​

PlayerNoise.Band(
bands: {NoiseBand},
speed: number
) → NoiseBand?--

The fastest band whose Speed is at or below speed, or nil.

Pure.

LoudnessOf​

PlayerNoise.LoudnessOf(
band: NoiseBand,
speed: number,
character: Model
) → number?--

The loudness to fire, or nil for no noise.

A band's loudness for this speed and character: the number, or what the function returns. 0, a negative or a non-number is nil, so the caller fires nothing. Pure.

new​

PlayerNoise.new(
signal: Signal<(
number?,
string?
)>,--

The signal your Hearing senses listen to.

bands: {NoiseBand},
) → PlayerNoise

Types

​

interface PlayerNoiseOptions {
RootName: string?--

The part under each character whose velocity and position are read. Default "HumanoidRootPart".

}

Starts listening on the server. Destroy it to stop.

Errors

TypeDescription
"bands need Speed, Every and Loudness"
"unknown option"

Destroy​

PlayerNoise.Destroy(self: PlayerNoise) → ()

Stops listening.

Show raw api
{
    "functions": [
        {
            "name": "Band",
            "desc": "Pure.",
            "params": [
                {
                    "name": "bands",
                    "desc": "",
                    "lua_type": "{ NoiseBand }"
                },
                {
                    "name": "speed",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "The fastest band whose `Speed` is at or below `speed`, or `nil`.",
                    "lua_type": "NoiseBand?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 92,
                "path": "lib/World/PlayerNoise.luau"
            }
        },
        {
            "name": "LoudnessOf",
            "desc": "A band's loudness for this speed and character: the number, or what the function returns.\n`0`, a negative or a non-number is `nil`, so the caller fires nothing. Pure.",
            "params": [
                {
                    "name": "band",
                    "desc": "",
                    "lua_type": "NoiseBand"
                },
                {
                    "name": "speed",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "character",
                    "desc": "",
                    "lua_type": "Model"
                }
            ],
            "returns": [
                {
                    "desc": "The loudness to fire, or `nil` for no noise.",
                    "lua_type": "number?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 112,
                "path": "lib/World/PlayerNoise.luau"
            }
        },
        {
            "name": "new",
            "desc": "Starts listening on the server. Destroy it to stop.",
            "params": [
                {
                    "name": "signal",
                    "desc": "The signal your Hearing senses listen to.",
                    "lua_type": "Signal<(Vector3, number?, string?)>"
                },
                {
                    "name": "bands",
                    "desc": "",
                    "lua_type": "{ NoiseBand }"
                },
                {
                    "name": "options",
                    "desc": "",
                    "lua_type": "PlayerNoiseOptions?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "PlayerNoise"
                }
            ],
            "function_type": "static",
            "errors": [
                {
                    "lua_type": "\"bands need Speed, Every and Loudness\"",
                    "desc": ""
                },
                {
                    "lua_type": "\"unknown option\"",
                    "desc": ""
                }
            ],
            "source": {
                "line": 132,
                "path": "lib/World/PlayerNoise.luau"
            }
        },
        {
            "name": "Destroy",
            "desc": "Stops listening.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "PlayerNoise"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 185,
                "path": "lib/World/PlayerNoise.luau"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "NoiseBand",
            "desc": "",
            "fields": [
                {
                    "name": "Speed",
                    "lua_type": "number",
                    "desc": "Studs per second at or above which this band applies. The fastest band a player reaches wins."
                },
                {
                    "name": "Every",
                    "lua_type": "number",
                    "desc": "Seconds between noises while in this band."
                },
                {
                    "name": "Loudness",
                    "lua_type": "number | (speed: number, character: Model) -> number?",
                    "desc": "Passed to the signal; a [Hearing] with `Range` hears it from `Range * Loudness` studs. A function is asked on every noise; `nil` or `0` makes none (a crouch off an attribute)."
                },
                {
                    "name": "Kind",
                    "lua_type": "string?",
                    "desc": "Passed as the third argument, written as `HeardKind` by [Hearing]."
                }
            ],
            "source": {
                "line": 36,
                "path": "lib/World/PlayerNoise.luau"
            }
        },
        {
            "name": "PlayerNoiseOptions",
            "desc": "",
            "fields": [
                {
                    "name": "RootName",
                    "lua_type": "string?",
                    "desc": "The part under each character whose velocity and position are read. Default `\"HumanoidRootPart\"`."
                }
            ],
            "source": {
                "line": 49,
                "path": "lib/World/PlayerNoise.luau"
            }
        }
    ],
    "name": "PlayerNoise",
    "desc": "Players make noise by moving. Give it the noise signal your [Hearing] senses listen to and the\nspeed bands; while a player moves at a band's speed or faster, a noise of that band is fired at\ntheir feet every `Every` seconds, with their character as the source. Standing still, or moving\nbelow the slowest band, is silent.\n\n```lua\nlocal function step(loudness)\n\treturn function(_speed, character)\n\t\treturn if character:GetAttribute(\"Crouching\") then nil else loudness\n\tend\nend\n\nVluxyAI.PlayerNoise.new(noises, {\n\t{ Speed = 4, Every = 0.7, Loudness = step(0.25), Kind = \"Footstep\" }, -- walking, silent crouched\n\t{ Speed = 19, Every = 0.5, Loudness = 0.6, Kind = \"Running\" },        -- sprinting\n})\n```",
    "source": {
        "line": 83,
        "path": "lib/World/PlayerNoise.luau"
    }
}