Setup & Structure
Getting DataReplicator into your game is super easy!
Get the Module
You can grab the latest version directly from the Roblox Creator Store: DataReplicator Model, or you can download the file here:
Place it in Your Game
Once you have the DataReplicator ModuleScript and its accompanying folders, the recommended place to put it is ReplicatedStorage. This ensures it's easily accessible to both server Scripts and client LocalScripts.
The module is organized with its core logic and dependencies neatly separated for clarity and maintainability.
Your hierarchy in ReplicatedStorage should look like this:
ReplicatedStorage
└── DataReplicator (ModuleScript) -- This is the main module you'll require
├── Dependencies (Folder)
│ ├── Cryptography (ModuleScript) -- Handles encryption and secure key generation by @XoifailTheGod
│ └── Signal (ModuleScript) -- A lightweight event signal implementation by @AlexanderLindholt
└── Internal (Folder)
├── Core (ModuleScript) -- Handles all the internal logic
└── Utilities (ModuleScript) -- Contains helper functions
Require the Module
Now, you can easily access DataReplicator from your server scripts and client LocalScripts.
From a Server Script (e.g., in
ServerScriptService):-- Location: ServerScriptService/MyTestScript local ReplicatedStorage = game:GetService("ReplicatedStorage") local DataReplicator = require(ReplicatedStorage.DataReplicator) local UPTIME_KEY = "ServerUptime" -- Create the data key with an initial value local success = DataReplicator:Create(UPTIME_KEY, math.floor(os.clock())) if success then print("[Server] DataReplicator key 'ServerUptime' created successfully.") end -- Continuously update the data every 5 seconds task.spawn(function() while true do task.wait(5) local newUptime = math.floor(os.clock()) DataReplicator:Update(UPTIME_KEY, newUptime, "All") print(`[Server] Updated 'ServerUptime' to: {newUptime}`) end end)From a LocalScript (e.g., inside a StarterPlayerScripts in
StarterPlayer):-- Location: StarterPlayer/StarterPlayerScripts/MyClientTest local ReplicatedStorage = game:GetService("ReplicatedStorage") local DataReplicator = require(ReplicatedStorage.DataReplicator) local UPTIME_KEY = "ServerUptime" print("[Client] Setting up listener for 'ServerUptime'...") -- Listen for changes to the key local uptimeSignal = DataReplicator:Listen(UPTIME_KEY) uptimeSignal:Connect(function(newUptime) if newUptime then print(`[Client] Received new server uptime: {newUptime}`) else print("[Client] 'ServerUptime' data was deleted.") end end)
And that's it! If you run your game with these two scripts, you will see the server printing its updates and the client printing the data it receives in real-time in your output console. You're all set to start using DataReplicator in your project.
Last updated