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},
}

Key Changes:

  • NEW: IsReady() for status checking
  • NEW: GetOfflineData(userId) for remote profile snapshots (see security notes in client API)
  • NEW: ClearCache() for manual cache management
  • NEW: Enhanced OnChanged() with ChangeInfo support
  • NEW: Better error handling and validation

Change callback usage ​

For client OnChanged, the third argument follows the same rules described on the client API page (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