It’s not the same, if you took time to see API of each module you would notice a somewhat major difference, especially the way you interact with them.
Primary goal of NetTbl is to focus on tables and remain minimalistic; as well as be simple, and easy to learn. You can think of Replica as IDE and NetTbl as a code editor. IDE does many different things and provides all kinds of features while code editor mostly focuses on code editing.
Pretty much the same thing can be said for those two, ReplicaService provides tons of features while NetTbl focuses on tables, replication, change tracking, minimalism, and simplicity; because it tries to simplify your workflow as much as possible.
Each system has it’s own pros and cons, therefore it’s up to you to decide what you need. If you need something more feature rich and advanced, use Replica, if you want something simple and minimalistic then go for NetTbl.
Creating Data
Replica.luau
local SessionData = ReplicaService.NewReplica({
ClassToken = ReplicaService.NewClassToken("SessionData"),
Data = {Value = 0},
Replication = "All",
})
NetTbl.luau
local SessionData = NetTbl:Add("SessionData", { Timer = 0 })
Retrieving Data
Replica.luau
ReplicaController.ReplicaOfClassCreated("SessionData", function(sessionData)
print(sessionData.Data.Timer) --> 0
end)
ReplicaController.RequestData()
NetTbl.luau
--[[
You can call this function in multiple lua containers without worry,
this is because NetTbl handles all of the magic for you!
]]
local SessionData = NetTbl:Get("SessionData")
print(SessionData.Value.Timer) --> 0
Reading Values
Replica.luau
print(SessionData.Data.Timer) --> 0
NetTbl.luau
print(SessionData.Value.Timer) --> 0
Changing Values
Replica.luau
for i = 100, 1, -1 do
SessionData:SetValue("Timer", i)
end
NetTbl.luau
for i = 100, 1, -1 do
SessionData.Value.Timer = i
end
Tracking Changes
Replica.luau
local function UpdateTimerDisplay(newValue, oldValue)
print(newValue, oldValue) --> 2, 1
end
SessionData:ListenToChange("Timer", UpdateTimerDisplay)
UpdateTimerDisplay(SessionData.Data.Timer) -- Initialization
NetTbl.luau
--[[
No need to initialize it yourself, you can pass true to the
NetTbl:Track function and it will do it for you.
]]
SessionData:Track("Timer", function(newValue, oldValue)
print(newValue, oldValue) --> 2, 1
end, true)