ServerSync – Real-Time Server Synchronization
ServerSync is a Roblox module designed to synchronize data across different server instances. It uses MessagingService
and DataStoreService
for efficient data management and real-time updates.
Key Features
- Real-Time Synchronization: Keeps data consistent across all server instances.
-
Event-Driven Architecture: Uses the
Signal
module to handle data changes. - Simple API: Easy to integrate and use in your projects.
Installation
- Download the Module: Obtain the module here: ServerSync.
-
Require the Module:
local ServerSync = require(game:GetService("ReplicatedStorage").ServerSync)
- Initialize the Module: Use the module as you need 😜
API Reference
ServerSync
-
ServerSync:CreateDataStore(Key: string): DataStore
-
Description: Creates a new
DataStore
with the specified key. -
Parameters:
-
Key
(string): The key for the newDataStore
.
-
-
Returns:
DataStore
- The newly createdDataStore
object.
-
Description: Creates a new
DataStore
-
DataStore:GetAsync(Key: string, Template: table): Data
- Description: Gets the data for a specific key asynchronously.
-
Parameters:
-
Key
(string): The key to retrieve data for. -
Template
(table): The template to use if data does not exist.
-
-
Returns:
Data
- TheData
object for the key.
-
DataStore:Get(Key: string, Template: table): Data
- Description: Gets the data for a specific key synchronously.
-
Parameters:
-
Key
(string): The key to retrieve data for. -
Template
(table): The template to use if data does not exist.
-
-
Returns:
Data
- TheData
object for the key.
-
DataStore:Release(Key: string)
- Description: Releases the data for a specific key.
-
Parameters:
-
Key
(string): The key to release data for.
-
Data
-
Data:Get(): any
- Description: Gets the current data.
-
Returns:
any
- The current data.
-
Data:SetAsync(Path: table, NewValue: any)
- Description: Sets the value at a specific path in the data table asynchronously.
-
Parameters:
-
Path
(table): The path to set the new value at. -
NewValue
(any): The new value to set.
-
-
Data:Release()
- Description: Releases the data and cleans up the associated resources.
Examples
Creating a DataStore:
local dataStore = ServerSync:CreateDataStore("MyDataStore")
Getting Synchronized Data:
local data = dataStore:GetAsync("Player123", {
stats = {
score = 0
}
)
print(data:Get())
Setting Data:
local playerData = dataStore:Get("Player123")
playerData:SetAsync({"stats", "score"}, 500)
Handling Data Changes:
local data = dataStore:Get("Player123")
data.Changed:Connect(function(newData)
print("Data changed:", newData)
end)
Support and Feedback
For support, please dm me from:
Discord: .furukan
X / Twitter: FurukanDev
Rate The Module!
- 1
- 2
- 3
- 4
- 5
0 voters