ServerReplicate
The server-side representation of a Replicate. This is the object that you interact with when setting up Replicates on the server.
Summary
Methods
| StartReplicating () : ServerReplicate |
| GetValue (path: ValuePath) : Variant |
| SetValue (path: ValuePath, value: Variant, temporary: boolean?) : Variant |
| Increment (path: ValuePath, value: number) : number |
| Ensure (path: ValuePath, defaultValue: Variant) : Variant |
| Delete (path: ValuePath) |
| ArrayInsert (path: ValuePath, value: Variant, temporary: boolean?) |
| ArrayRemove (path: ValuePath, index: number) : Variant |
| ArrayFind (path: ValuePath, value: Variant) : number? |
| Destroy () |
Methods
StartReplicating
ServerReplicate:StartReplicating ( ) : ServerReplicate
Tip
All GetReplicate calls will yield until ServerReplicate:StartReplicating() has been called. You should call this method as soon as the Replicate's initial data has been set.
GetValue
ServerReplicate:GetValue ( path: ValuePath ) : Variant
Parameters
| path : ValuePath |
Returns
| Variant |
SetValue
ServerReplicate:SetValue (
path: ValuePath, value: Variant, temporary: boolean?
) : Variant
Parameters
| path : ValuePath |
| value : Variant |
| temporary : boolean? Whether the inserted item should be temporary or not. |
Returns
| Variant The previous value at the given path, or nil if there was no value. |
Understanding Temporary Values
When using the "reference" SourceMode, you can set temporary values that wont save to the referenced source data table. For example, lets say you're loading player data from something like ProfileStore or DataStoreService and you want to give them a skin for this server only, you could do something like this:
Increment
ServerReplicate:Increment ( path: ValuePath, value: number ) : number
Parameters
| path : ValuePath |
| value : number |
Returns
| number The new value at the given path after the increment. |
Ensure
ServerReplicate:Ensure ( path: ValuePath, defaultValue: Variant ) : Variant
Parameters
| path : ValuePath |
| defaultValue : Variant |
Returns
| Variant The current value, or defaultValue if nil. |
Delete
ServerReplicate:Delete ( path: ValuePath ) : ()
Parameters
| path : ValuePath |
ArrayInsert
ServerReplicate:ArrayInsert (
path: ValuePath, value: Variant, temporary: boolean?
) : ()
Parameters
| path : ValuePath |
| value : Variant The value to append to the array. |
| temporary : boolean? Whether the inserted item should be temporary or not. Read more. |
ArrayRemove
ServerReplicate:ArrayRemove ( path: ValuePath, index: number ) : Variant
Parameters
| path : ValuePath |
| index : number |
Returns
| Variant The value that was removed from the array. |
ArrayFind
ServerReplicate:ArrayFind ( path: ValuePath, value: Variant ) : number?
Parameters
| path : ValuePath |
| value : Variant |
Returns
| number? The index of the first occurrence of the value in the array, or nil. |
Destroy
ServerReplicate:Destroy ( ) : ()
Danger
Only destroy Replicates when players are leaving! Once a player's Replicate is destroyed, they cannot receive more data unless they rejoin. This is a limitation of how Replicates are handled and may change in the future.