Skip to main content

DatastoreModule

This item only works when running on the server. Server

The projects DataStore, all data runs through the DatastoreModule.

Types

PlayerProfileType

type PlayerProfileType = {
PlayerDatastore:StartSessionAsync("",
{})
}

SlotData

type SlotData = typeof(SlotDataTemplate)

The type definition for a single character slot, inferred from SlotDataTemplate.

Functions

OnPlayerAdded

DatastoreModule.OnPlayerAdded(playerPlayer) → ()

Runs whenever a player is loaded. Grabs a players profile, kicks if the profile isn't present

GrabPlayerProfile

DatastoreModule.GrabPlayerProfile(playerPlayer) → PlayerProfileType--

Player profile

Grabs & returns a players profile, returns nil if the profile isn't found.

GrabPlayerSlotData

DatastoreModule.GrabPlayerSlotData(playerPlayer) → {any}--

Slot Data

Grabs & returns a players slot data, returns nil if the profile isn't found.

WaitForProfile

DatastoreModule.WaitForProfile(
playerPlayer,
timeoutnumber?--

Defaults to 10 seconds

) → PlayerProfileType | nil

Waits for a players profile, returns nil if the profile isn't found.

WaitForSlotData

DatastoreModule.WaitForSlotData(
playerPlayer,
timeoutnumber?--

Defaults to 10 seconds

) → {any}--

Slot Data

Waits for a players profile, returns nil if the profile isn't found.

GrabPlayerProfiles

DatastoreModule.GrabPlayerProfiles() → {[Player]PlayerProfileType}

Grabs all player profiles currently loaded.

ClearProfile

DatastoreModule:ClearProfile(playerPlayer) → ()

Saves a players data and unloads it from the DataStore.

CAUTION

It's worth to note that this doesn't delete data, it merely saves it.

Show raw api
{
    "functions": [
        {
            "name": "OnPlayerAdded",
            "desc": "Runs whenever a player is loaded. Grabs a players profile, kicks if the profile isn't present",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 96,
                "path": "global/ServerStorage/Scripts/Modules/DatastoreModule.luau"
            }
        },
        {
            "name": "GrabPlayerProfile",
            "desc": "Grabs & returns a players profile, returns nil if the profile isn't found.",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                }
            ],
            "returns": [
                {
                    "desc": "Player profile",
                    "lua_type": "PlayerProfileType"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 142,
                "path": "global/ServerStorage/Scripts/Modules/DatastoreModule.luau"
            }
        },
        {
            "name": "GrabPlayerSlotData",
            "desc": "Grabs & returns a players slot data, returns nil if the profile isn't found.",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                }
            ],
            "returns": [
                {
                    "desc": "Slot Data",
                    "lua_type": "{any}"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 158,
                "path": "global/ServerStorage/Scripts/Modules/DatastoreModule.luau"
            }
        },
        {
            "name": "WaitForProfile",
            "desc": "Waits for a players profile, returns nil if the profile isn't found.",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                },
                {
                    "name": "timeout",
                    "desc": "Defaults to 10 seconds",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "PlayerProfileType | nil"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 179,
                "path": "global/ServerStorage/Scripts/Modules/DatastoreModule.luau"
            }
        },
        {
            "name": "WaitForSlotData",
            "desc": "Waits for a players profile, returns nil if the profile isn't found.",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                },
                {
                    "name": "timeout",
                    "desc": "Defaults to 10 seconds",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "Slot Data",
                    "lua_type": "{any}"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 202,
                "path": "global/ServerStorage/Scripts/Modules/DatastoreModule.luau"
            }
        },
        {
            "name": "GrabPlayerProfiles",
            "desc": "Grabs all player profiles currently loaded.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ [Player]: PlayerProfileType }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 222,
                "path": "global/ServerStorage/Scripts/Modules/DatastoreModule.luau"
            }
        },
        {
            "name": "ClearProfile",
            "desc": "Saves a players data and unloads it from the DataStore.\n:::caution\nIt's worth to note that this doesn't delete data, it merely saves it.\n:::",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 235,
                "path": "global/ServerStorage/Scripts/Modules/DatastoreModule.luau"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "PlayerProfileType",
            "desc": "",
            "lua_type": "{PlayerDatastore:StartSessionAsync(\"\", {})}",
            "source": {
                "line": 36,
                "path": "global/ServerStorage/Scripts/Modules/DatastoreModule.luau"
            }
        },
        {
            "name": "SlotData",
            "desc": "The type definition for a single character slot, inferred from SlotDataTemplate.",
            "lua_type": "typeof(SlotDataTemplate)",
            "source": {
                "line": 43,
                "path": "global/ServerStorage/Scripts/Modules/DatastoreModule.luau"
            }
        }
    ],
    "name": "DatastoreModule",
    "desc": "The projects DataStore, all data runs through the DatastoreModule.",
    "realm": [
        "Server"
    ],
    "source": {
        "line": 9,
        "path": "global/ServerStorage/Scripts/Modules/DatastoreModule.luau"
    }
}