Skip to content

Client Interface Types

PlayerStateClient

The enhanced client module interface with all available functions.

lua
export type PlayerStateClient = {
    Get: (key: string) -> any,
    GetPath: (path: ValuePath) -> any,
    GetFromDict: (dictPath: ValuePath, key: string | number) -> any,
    Clone: (value: any, deep: boolean?) -> any,
    GetAll: () -> PlayerData?,
    GetOfflineData: (userId: number) -> PlayerData?,

    OnChanged: (pathOrKey: string, callback: ChangeCallback) -> ReplicaClient.Connection?,

    GetReplica: () -> ReplicaInstance?,

    IsReady: () -> boolean,

    GetShared: (key: string) -> any,
    GetSharedPath: (path: ValuePath) -> any,
    OnSharedChanged: (pathOrKey: string, callback: ChangeCallback) -> ReplicaClient.Connection?,
    GetSharedReplica: () -> ReplicaInstance?,
    GetSharedAll: () -> {[string]: any}?,
    IsSharedReady: () -> boolean,

    ClearCache: () -> (),

    GetLeaderboardInfo: (statName: string) -> LeaderboardInfo?,
    GetLeaderboard: (statName: string, limit: number?) -> {LeaderboardEntry},
}

Related APIs: IsReady(), GetOfflineData(userId), ClearCache(), and OnChanged() with ChangeInfo — see Client API and What's new.

Change callback usage

For client OnChanged, see the Change listeners guide (ChangeInfo vs path segments).

Parameters:

  • newValue: The new value after the change
  • oldValue: The previous value before the change
  • changeInfo: Enhanced change information with action details OR simple path array

Example with Action Handling:

lua
local connection = PlayerState.OnChanged("Inventory", function(newValue, oldValue, info)
    if info and typeof(info) == "table" and info.action then
        -- Enhanced change info
        if info.action == "TableInsert" then
            print(`Item added at index {info.index}`)
        elseif info.action == "TableRemove" then
            print(`Item removed from index {info.index}`)
        end
    else
        -- Simple path info
        print("Inventory changed")
    end
end)

PlayerState - High-Performance Roblox Data Management