Skip to main content

SkillTree

The server-side skill tree instance. Manages unlock logic, currency, and player state.

Properties

NodeUnlocked

SkillTree.NodeUnlocked: Signal<string,string,number>

Fired when a node is successfully unlocked or upgraded. Arguments: playerId, nodeId, rank.

Functions

new

SkillTree.new(
configSkillTreeConfig--

The skill tree configuration

) → SkillTree

Creates a new SkillTree instance.

addPoints

SkillTree:addPoints(
playerIdstring,--

The UserId as a string

currencystring,--

The currency name

amountnumber--

Amount to add

) → boolean--

True if successful

Adds points to a player's currency balance.

unlock

SkillTree:unlock(
playerIdstring,--

The UserId as a string

nodeIdstring--

The node identifier from SkillTreeConfig

) → UnlockResult--

{ success: boolean, reason: string }

Attempts to unlock a node for the given player.

upgrade

SkillTree:upgrade(
playerIdstring,--

The UserId as a string

nodeIdstring--

The node identifier

) → UnlockResult--

{ success: boolean, reason: string }

Upgrades a multi-rank node for the given player.

getState

SkillTree:getState(
playerIdstring--

The UserId as a string

) → PlayerSkillState?--

The player's state, or nil if not loaded

Retrieves the current state for a player.

getNode

SkillTree:getNode(
nodeIdstring--

The node identifier

) → NodeConfig?--

The node config, or nil if not found

Retrieves a node configuration by ID.

respec

SkillTree:respec(
playerIdstring--

The UserId as a string

) → boolean--

True if successful

Resets a player's skill tree state, refunding all points.

loadPlayer

SkillTree:loadPlayer(
playerIdstring--

The UserId as a string

) → boolean--

True if successful

Loads a player's skill tree state from storage.

savePlayer

SkillTree:savePlayer(
playerIdstring--

The UserId as a string

) → boolean--

True if successful

Saves a player's skill tree state to storage.

unloadPlayer

SkillTree:unloadPlayer(
playerIdstring--

The UserId as a string

) → ()

Unloads and releases a player's data from memory.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Creates a new SkillTree instance.",
            "params": [
                {
                    "name": "config",
                    "desc": "The skill tree configuration",
                    "lua_type": "SkillTreeConfig"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "SkillTree"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 56,
                "path": "src/SkillTree.luau"
            }
        },
        {
            "name": "addPoints",
            "desc": "Adds points to a player's currency balance.",
            "params": [
                {
                    "name": "playerId",
                    "desc": "The UserId as a string",
                    "lua_type": "string"
                },
                {
                    "name": "currency",
                    "desc": "The currency name",
                    "lua_type": "string"
                },
                {
                    "name": "amount",
                    "desc": "Amount to add",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "True if successful",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 109,
                "path": "src/SkillTree.luau"
            }
        },
        {
            "name": "unlock",
            "desc": "Attempts to unlock a node for the given player.",
            "params": [
                {
                    "name": "playerId",
                    "desc": "The UserId as a string",
                    "lua_type": "string"
                },
                {
                    "name": "nodeId",
                    "desc": "The node identifier from SkillTreeConfig",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "{ success: boolean, reason: string }",
                    "lua_type": "UnlockResult"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 144,
                "path": "src/SkillTree.luau"
            }
        },
        {
            "name": "upgrade",
            "desc": "Upgrades a multi-rank node for the given player.",
            "params": [
                {
                    "name": "playerId",
                    "desc": "The UserId as a string",
                    "lua_type": "string"
                },
                {
                    "name": "nodeId",
                    "desc": "The node identifier",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "{ success: boolean, reason: string }",
                    "lua_type": "UnlockResult"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 207,
                "path": "src/SkillTree.luau"
            }
        },
        {
            "name": "getState",
            "desc": "Retrieves the current state for a player.",
            "params": [
                {
                    "name": "playerId",
                    "desc": "The UserId as a string",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "The player's state, or nil if not loaded",
                    "lua_type": "PlayerSkillState?"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 254,
                "path": "src/SkillTree.luau"
            }
        },
        {
            "name": "getNode",
            "desc": "Retrieves a node configuration by ID.",
            "params": [
                {
                    "name": "nodeId",
                    "desc": "The node identifier",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "The node config, or nil if not found",
                    "lua_type": "NodeConfig?"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 261,
                "path": "src/SkillTree.luau"
            }
        },
        {
            "name": "respec",
            "desc": "Resets a player's skill tree state, refunding all points.",
            "params": [
                {
                    "name": "playerId",
                    "desc": "The UserId as a string",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "True if successful",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 268,
                "path": "src/SkillTree.luau"
            }
        },
        {
            "name": "loadPlayer",
            "desc": "Loads a player's skill tree state from storage.",
            "params": [
                {
                    "name": "playerId",
                    "desc": "The UserId as a string",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "True if successful",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 298,
                "path": "src/SkillTree.luau"
            }
        },
        {
            "name": "savePlayer",
            "desc": "Saves a player's skill tree state to storage.",
            "params": [
                {
                    "name": "playerId",
                    "desc": "The UserId as a string",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "True if successful",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 315,
                "path": "src/SkillTree.luau"
            }
        },
        {
            "name": "unloadPlayer",
            "desc": "Unloads and releases a player's data from memory.",
            "params": [
                {
                    "name": "playerId",
                    "desc": "The UserId as a string",
                    "lua_type": "string"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 321,
                "path": "src/SkillTree.luau"
            }
        },
        {
            "name": "_buildNodeMap",
            "desc": "",
            "params": [
                {
                    "name": "config",
                    "desc": "",
                    "lua_type": "SkillTreeConfig"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ [string]: NodeConfig }\n"
                }
            ],
            "function_type": "static",
            "private": true,
            "source": {
                "line": 327,
                "path": "src/SkillTree.luau"
            }
        },
        {
            "name": "_getRank",
            "desc": "",
            "params": [
                {
                    "name": "state",
                    "desc": "",
                    "lua_type": "PlayerSkillState"
                },
                {
                    "name": "nodeId",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number\n"
                }
            ],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 348,
                "path": "src/SkillTree.luau"
            }
        },
        {
            "name": "_canAfford",
            "desc": "",
            "params": [
                {
                    "name": "state",
                    "desc": "",
                    "lua_type": "PlayerSkillState"
                },
                {
                    "name": "cost",
                    "desc": "",
                    "lua_type": "CostMap"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean\n"
                }
            ],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 353,
                "path": "src/SkillTree.luau"
            }
        },
        {
            "name": "_spendPoints",
            "desc": "",
            "params": [
                {
                    "name": "state",
                    "desc": "",
                    "lua_type": "PlayerSkillState"
                },
                {
                    "name": "cost",
                    "desc": "",
                    "lua_type": "CostMap"
                }
            ],
            "returns": [],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 370,
                "path": "src/SkillTree.luau"
            }
        },
        {
            "name": "_normalizePersistedState",
            "desc": "Strips datastore-injected currencies and clamps balances before any economy mutation.",
            "params": [
                {
                    "name": "state",
                    "desc": "",
                    "lua_type": "PlayerSkillState"
                }
            ],
            "returns": [],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 382,
                "path": "src/SkillTree.luau"
            }
        },
        {
            "name": "_isConfiguredCurrency",
            "desc": "",
            "params": [
                {
                    "name": "currency",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean\n"
                }
            ],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 403,
                "path": "src/SkillTree.luau"
            }
        }
    ],
    "properties": [
        {
            "name": "NodeUnlocked",
            "desc": "Fired when a node is successfully unlocked or upgraded. Arguments: playerId, nodeId, rank.",
            "lua_type": "Signal<string, string, number>",
            "source": {
                "line": 52,
                "path": "src/SkillTree.luau"
            }
        }
    ],
    "types": [],
    "name": "SkillTree",
    "desc": "The server-side skill tree instance. Manages unlock logic, currency, and player state.",
    "source": {
        "line": 19,
        "path": "src/SkillTree.luau"
    }
}