Getting Started
Learn how to use Unify effectively.
How Unify works
Unify works consistently across both the client and the server. The standard pattern is to create a single loader script on each side, which loads and connects your modules using a clean, promise-based workflow.
Loader (Client or Server)
Use the following pattern to initialize modules on either the client or the server:
local Unify = require(game:GetService("ReplicatedStorage").Packages.Unify)
Unify:Add(script.Parent.Modules)
:andThen(function()
print("Modules loaded successfully.")
end)
:catch(function(err)
warn("Failed to load modules:", err)
end)
:finally(function()
print("Loading complete.")
end)
Example: Client Module
local Unify = require(game:GetService("ReplicatedStorage").Packages.Unify)
local Clicks = {}
function Clicks.onActivated()
ClicksServer:Click()
end
local ClicksServer = Unify:Get("ClicksServer")
return Clicks
Example: Server Module
local Unify = require(game:GetService("ReplicatedStorage").Packages.Unify)
local DataServer: typeof(require(script.Parent.Parent.Framework.DataServer))
local Clicks = {
Client = {},
}
function Clicks.Client:Click(...: any)
return self.Server:Click(...)
end
function Clicks:Click(player: Player)
local playerData = DataServer:GetAsync(player)
playerData.Clicks += 1
end
DataServer = Unify:Get("DataServer")
return Clicks
Defining Remotes
local Pets = {
Client = {},
}
function Pets.Client:Equip(...: any)
-- Forwards the equip request to the server-side Equip function
return self.Server:Equip(...)
end
function Pets.Client.Equipped(...: any)
-- Stub function: intentionally left empty.
-- This allows the server to fire the event to the client without requiring a client-side handler.
return
end
function Pets:Equip(player: Player, petId: string)
-- Handles equipping a pet for the player on the server side
-- Notifies the client that a pet has been equipped
self.Client.Equipped:Fire(player)
end
Strict Remote Format
You must follow this strict pattern for defining remotes, as it is regarded as the best practice for Unify to ensure clarity and consistency.
You’re now ready to build powerful, scalable systems using Unify on both the client and the server.