Sharing table across Server-Client boundary

If I were to send a table from a server script to a local script via remote events/functions, will the table become a referenced table or cloned table?

You would get a cloned table. The client wouldn’t (and shouldn’t) be able to modify the one on the server.

Copied, just bare in mind that metatables are lost in the network transmission. To remedy this you can send both individually.

--SERVER

local Table = setmetatable({}, {
	__index = function(Table, Key)
		return rawget(Table, Key)
	end,
	
	__newindex = function(Table, Key, Value)
		return rawset(Table, Key, Value)
	end
})

local Metatable = getmetatable(Table)
RemoteEvent:FireClient(Table, Metatable)
--CLIENT

local function OnRemoteEventFired(Table, Metatable)
	setmetatable(Table, Metatable)
end

RemoteEvent.OnClientEvent:Connect(OnRemoteEventFired)
2 Likes