rev_ReplicaCreate.OnClientEvent:Connect(function(P,z)local k={}if type(P)=="\116\097\098\108\101"then table.sort(P,function(P,z)return P[1]<z[1]end)for P,z in ipairs(P)do CreateReplicaBranch(z[2],k)end elseif z[1]~=nil then CreateReplicaBranch({[tostring(P)]=z},k)else CreateReplicaBranch(z,k)end table.sort(k,function(P,z)return P.Id<z.Id end)for P,z in ipairs(k)do local k=z.Parent if k~=nil then local P=ChildListeners[k.Id]if P~=nil then for k=1,#P,1 do P[k](z)end end end end for P,z in ipairs(k)do NewReplicaSignal:Fire(z)local k=ClassListeners[z.Class]if k~=nil then k:Fire(z)end end end)

rev_ReplicaCreate.OnClientEvent:Connect(function(param1, param2) -- (top_replica_id, {replica_data}) OR (top_replica_id, {creation_data}) or ({replica_package})
	--[[
	param1 description:
		top_replica_id = replica_id
		OR
		replica_package = {{replica_id, creation_data}, ...}
	param2 description:
		replica_data = {replica_class, replica_tags, data_table, parent_id / 0, write_lib_module / nil}
		OR
		creation_data = {["replica_id"] = replica_data, ...}
	--]]
	local created_replicas = {}
	-- Unpacking replica data:
	if type(param1) == "table" then -- Replica package
		table.sort(param1, function(a, b) -- Sorting top level replicas by their id
			return a[1] < b[1]
		end)
		for _, replica_branch_entry in ipairs(param1) do
			CreateReplicaBranch(replica_branch_entry[2], created_replicas)
		end
	elseif param2[1] ~= nil then -- One replica data
		CreateReplicaBranch({[tostring(param1)] = param2}, created_replicas)
	else -- Creation data table
		CreateReplicaBranch(param2, created_replicas)
	end
	-- Broadcasting replica creation:
	table.sort(created_replicas, function(a, b)
		return a.Id < b.Id
	end)
	-- 1) Child added:
	for _, replica in ipairs(created_replicas) do
		local parent_replica = replica.Parent
		if parent_replica ~= nil then
			local child_listener_table = ChildListeners[parent_replica.Id]
			if child_listener_table ~= nil then
				for i = 1, #child_listener_table do
					child_listener_table[i](replica)
				end
			end
		end
	end
	-- 2) New Replica and Replica of class created:
	for _, replica in ipairs(created_replicas) do
		NewReplicaSignal:Fire(replica)
		local class_listener_signal = ClassListeners[replica.Class]
		if class_listener_signal ~= nil then
			class_listener_signal:Fire(replica)
		end
	end
end)
