How do you know when a container replicates fully?

I have a Folder full of values, yet when I parent it to the workspace on the server the client will see 0 children on the first frame (through a childadded event). If I wait a frame, the children will appear.

So I wrote a test using 10,000 values inside the folder, and printed the values on ChildAdded and each subsequent frame on the client:
image
For this folder of 10,000 values it took >10 steps to replicate all children.

As a developer - how do you know once all children of a container have replicated? I wrote a RemoteEvent to send the “true” number to the client, but re-implementing networking guarantees feels like something a developer shouldn’t be doing. Is there any built-in functionality for this?

Test Server Code:

function MakeFolder()
	local f = Instance.new("Folder")
	for i = 1, 10000 do
		local value = Instance.new("IntValue")
		value.Name = tostring(i)
		value.Parent = f
	end
	f.Parent = workspace
end

wait(5)
MakeFolder()

Test Client Code:

workspace.ChildAdded:connect(function(c)
	print(c.Name.." #"..#c:GetChildren())
	for i = 1, 10 do
		wait()
		print(c.Name.." #"..#c:GetChildren())
	end
end)
1 Like

One method is to have the server count how many values there should be and send it to the client or maybe put in as an IntValue then have the client wait until the quantity of children is the same as the server told the client

Engine doesn’t support this at the moment to the best of my knowledge. The client never knows how much the server is going to be replicating and the server can’t exactly tell the client how much to expect either. You can send the amount of children and have the client wait until the amount of children are the same, sure, but it doesn’t really guarantee descendants have replicated as well (?) nor the full amount that the server needs to replicate over.

1 Like