I'm working on a complete rewrite of all my code, please excuse any messy code that I haven't done yet.

I've used this system to transfer object data from the server to the client for awhile. It seems to work fine but the method just doesn't sit right with me.

I have a RemoteEvent that when triggered pulls the requested instance from ServerStorage and places it in ReplicatedStorage under a folder named the player's UserId. The client waits for that folder to appear and then uses that instance for whatever it needs.

Its efficient, I've managed to cut down wait times to mere milliseconds, but I feel like its something I will want to change in the long run, especially as it makes all the data transfers public to anyone on the server. For some reason it also errors when you try to disconnect and reconnect to a broadcast, but I can fix that on my own. I will eventually need to connect this to a data store as well, which is a whole other issue.

This specific code is for connecting to a live broadcast which includes audio and gui. There is more code then just this but its all you really need to get a grasp on the idea.

LocalScript

function broadcast.connect(Id)
	game.Players.LocalPlayer.PlayerGui.Viewer.Loading.Visible = true
	game.ReplicatedStorage.clientPipeline.Broadcast.openBroadcast:InvokeServer(Id)
	local connectedBroadcast = game.ReplicatedStorage.clientPipeline.InstanceTransfer[game.Players.LocalPlayer.Name]:GetChildren()
	connectedBroadcast[1].Parent = game.Players.LocalPlayer.PlayerScripts.connectedTo
	local GuiAssets = connectedBroadcast[1]["2dSpace"]:GetChildren()
	local Assets = connectedBroadcast[1]["3dSpace"]:GetChildren()
	local Scripts = connectedBroadcast[1]["Scripts"]:GetChildren()
	for i = 1,#GuiAssets do
		local x = GuiAssets[i]:Clone()
		x.Parent = game.Players.LocalPlayer.PlayerGui.Viewer.Window
	end
	for i = 1,#Assets do
		local x = Assets[i]:Clone()
		x.Parent = game.Players.LocalPlayer.PlayerGui.Viewer["3D"]
	end
	for i = 1,#Scripts do
		Scripts[i].Disabled = false
	end
	broadcast.sync()
end

ServerScript

game.ReplicatedStorage.clientPipeline.Broadcast.openBroadcast.OnServerInvoke = function(player, Id)
	local broadcasts = game.ServerStorage.broadcasts:GetChildren()
	for i=1,#broadcasts do
		if broadcasts[i].Id.Value == Id then
			game.ReplicatedStorage.clientPipeline.InstanceTransfer:ClearAllChildren()
			local x = Instance.new("Folder", game.ReplicatedStorage.clientPipeline.InstanceTransfer)
			x.Name = player.Name
			local y = broadcasts[i]:Clone()
			y.Parent = x
			local children = broadcasts[i].dataStore.connectedPlayers:GetChildren()
			for i = 1, #children do
				for l = 1, #children do
					if children[i].Value == children[l].Value and children[i] ~= children[l] then
						children[l]:Destroy()
					end
				end
			end
			local z = Instance.new("IntValue", broadcasts[i].dataStore.connectedPlayers)
			z.Value = player.UserId
		end
	end
end

#Any ideas?