DataController
Handles data replication coming from the server.
Functions
GetDataReplica
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsDataController:GetDataReplica() → Replica
Returns the Replica object that contains player data. Yields until the
replica is available.
GetData
DataController:GetData() → {[string]: any}Returns the top-level player data table containing both session and profile data.
WARNING
This table is read-only. Do not attempt to write to it directly.
GetValue
DataController:GetValue(keyPath: string | {string}--
The dot-separated path or array of keys
) → any?Returns the value at the specified path in the player data table. Paths can be dot-separated strings or string arrays.
DataController:GetValue("SomeKey.SomeOtherKey")
-- OR
DataController:GetValue({"SomeKey", "SomeOtherKey"})
Observe
DataController:Observe(path: string,--
The dot-separated path to observe
callback: function--
Called with (newValue, oldValue) immediately and on every change
) → RBXScriptConnection
Immediately invokes callback with the current value at path, then
listens for changes and invokes it again on every subsequent update.
DataController:Observe("SomeKey.SomeOtherKey", function(newValue, oldValue)
print("Value changed from", oldValue, "to", newValue)
end)
SetValueCallback
DataController:SetValueCallback(path: string | {string},--
The path to listen to
callback: function,--
Called with (newValue, oldValue) on change
runImmediately: boolean?--
Whether to invoke the callback immediately with the current value
) → RBXScriptConnection
Sets a callback to be run when the value at path changes. If
runImmediately is true, behaves identically to Observe and invokes the
callback with the current value right away.