Introduction
Have you ever had trouble replicating values between the server and client? Do you find sending signals between client and server a hassle, having to create RemoteEvents and RemoteFunctions for every little thing you replicate? Do you often find Replication modules to be complicated, abstract, or hard to utilize?
If you find any of the scenarios above to be relatable, then this module might be the perfect fix to your problems! I’d like to introduce EZReplicator, a module made with the sole purpose of replicating values between client and server with a very easy to use module! With EZReplicator, server-client replication is hassle-free. No more creating RemoteEvents or RemoteFunctions for every little thing you may need to replicate. Instead, create a Subscription object, or send signals and request data via the EZReplicator module!
The benefits of using EZReplicator for replication purposes in your experience are:
- Easy to learn - EZReplicator is a module that is very easy to learn. It is meant to be beginner friendly, using mostly Getter and Setter functions
- Easily organize anything replication - EZReplicator makes it easy to organize your RemoteEvents and RemoteFunctions, because, with this module, there is no need to create any RemoteEvents or RemoteFunctions!
- Reliable, easy to fix errors - EZReplicator is meant to be a reliable module. It outputs custom error messages, making it easy to spot and fix errors
Example Code
To show how simple it can be to use, let’s look at some example code!
In the server,
--// services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--// modules
local EZReplicator = require(ReplicatedStorage:WaitForChild("EZReplicator"))
--// create subscription
local MAIN_SUBSCRIPTION = EZReplicator:CreateSubscription("MAIN", {
Foo = "Bar",
Hotel = "Trivago",
})
--// wait for a bit so that the client gets the subscription
task.wait(5)
--// add some new properties and change some property values
--// this should replicate the properties in the client
--// it also fires a signal in the client
MAIN_SUBSCRIPTION:AddProperty("New Property", "Something in here")
MAIN_SUBSCRIPTION:AddProperty("New Property 2", "Something else in here")
MAIN_SUBSCRIPTION:SetProperty("Foo", "Wassup homie")
In the client,
--// services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--// modules
local EZReplicator = require(ReplicatedStorage:WaitForChild("EZReplicator"))
--// wait for main subscription
local MAIN_SUBSCRIPTION = EZReplicator:WaitForSubscription("MAIN")
--// detect when a property has been changed in the MAIN subscription
--// this basically logs any changes made to the subscription
MAIN_SUBSCRIPTION.PropertyChanged:Connect(function(propIndex, propValue)
print(tostring(propIndex) .. ": " .. tostring(propValue))
end)
This code should print an output every time a property in the created Subscription
is changed! It’s that simple!
Summary
This module is completely open source, you can get it here!
Would you like to see the full documentation of EZReplicator? Well luckily, I documented it!
https://bhristt.github.io/EZReplicator/
Want to see the github repository, or add EZReplicator to your experience using Rojo? Here’s the github repository link!
I hope this helps you out in any of your server-client replication needs!