Skip to main content

Optional

Calls require on object or path, returning nil if it does not exist.

Functions

Get

Optional.Get(
objectInstance | string--

The object or path to require.

) → any?--

The module if it exists, or nil if it does not.

local Module = Optional.Get("ModulePath")
Show raw api
{
    "functions": [
        {
            "name": "Get",
            "desc": "```lua\nlocal Module = Optional.Get(\"ModulePath\")\n```",
            "params": [
                {
                    "name": "object",
                    "desc": "The object or path to require.",
                    "lua_type": "Instance | string"
                }
            ],
            "returns": [
                {
                    "desc": "The module if it exists, or nil if it does not.",
                    "lua_type": "any?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 17,
                "path": "src/Packages/Optional/init.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Optional",
    "desc": "Calls `require` on object or path, returning nil if it does not exist.",
    "source": {
        "line": 6,
        "path": "src/Packages/Optional/init.luau"
    }
}