Skip to main content

RngHandler

Provides utility functions for random number generation and weighted rolls.

Functions

RollByWeight

RngHandler.RollByWeight(
tableList{any}--

A list of items to roll from.

) → any?--

The selected item, or nil if weights are missing.

Selects an item from a list based on its weight. The provided table elements must contain a Weight property.

Show raw api
{
    "functions": [
        {
            "name": "RollByWeight",
            "desc": "Selects an item from a list based on its weight.\nThe provided table elements must contain a `Weight` property.",
            "params": [
                {
                    "name": "tableList",
                    "desc": "A list of items to roll from.",
                    "lua_type": "{any}"
                }
            ],
            "returns": [
                {
                    "desc": "The selected item, or nil if weights are missing.",
                    "lua_type": "any?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 20,
                "path": "global/ReplicatedStorage/Scripts/Modules/RngHandler.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "RngHandler",
    "desc": "Provides utility functions for random number generation and weighted rolls.",
    "source": {
        "line": 11,
        "path": "global/ReplicatedStorage/Scripts/Modules/RngHandler.luau"
    }
}