Appearance
Shared Session Functions β
Server-wide SharedSession state is separate from per-player profile data. It is not saved, is scoped to the current server, and syncs to all clients via a dedicated Replica. Configure defaults in PlayerStateConfig.Server.SharedSession (the table itself is the templateβno nested Template key).
For concepts and examples, see Shared Session and Data visibility.
SetShared() β
SetShared(key: string, value: any) β boolean
Sets a value at a top-level shared key only. If you need dot path syntax, use SetSharedPath.
Parameters: key: string, value: any
Returns: boolean β success
GetShared() β
GetShared(key: string) β any
Gets a value by top-level key.
Parameters: key: string
Returns: any
SetSharedPath() β
SetSharedPath(path: string, value: any) β boolean
Sets a value using dot notation (e.g. round.phase).
Parameters: path: string, value: any
Returns: boolean
GetSharedPath() β
GetSharedPath(path: string) β any
Gets a value using dot notation.
Parameters: path: string
Returns: any
SetSharedValues() β
SetSharedValues(values: { [string]: any }) β boolean
Applies multiple top-level key updates in one call.
Parameters: values β map of root key β value
Returns: boolean
OnSharedChanged() β
OnSharedChanged(pathOrKey: string, callback) β Connection?
Subscribes to SharedSession changes on the server (same path rules as player OnChanged for key vs path).
Returns: Connection? β disconnect when done, or nil if invalid
GetSharedReplica() β
GetSharedReplica() β ReplicaInstance?
Returns the raw SharedSession Replica for advanced use.
Returns: ReplicaInstance?
GetSharedAll() β
GetSharedAll() β table?
Returns the full shared session data table when available.
Returns: table?
IsSharedReady() β
IsSharedReady() β boolean
Whether the SharedSession Replica is ready for reads/writes.
Returns: boolean
Example
lua
PlayerState.SetSharedPath("round.phase", "Active")
PlayerState.SetSharedPath("round.endsAt", workspace:GetServerTimeNow() + 120)
PlayerState.OnSharedChanged("round.phase", function(newPhase)
print("Phase:", newPhase)
end)