Stop client outgoing data when the server moves objects?

Hello! I am currently working on an FPS PvE type of game, where there are a ton of enemies updating their positions at 16Hz. I’ve been working today on lowering the throughput of my most expensive remotes, and everything was going fine, until I opened the network debugging menu and I saw that the client was sending almost half of what it was receiving.

After that, I started debugging lots of stuff, to no avail. I also tried disabling all of my client-side scripts, but it didn’t change almost anything! I also tried playing it out of studio, on the actual Roblox client, but the result was the same. That’s when I thought it was something to do with the weird replication system of Roblox, so I made another place to test my theory out.

And so it was! I threw together a small script to test that, and the outgoing data from the client turned out to be relatively high. This is the script I wrote, if you want to test it out for yourself:

local xoff, yoff = -50, -120

task.wait(2)

local folder = Instance.new("Folder", workspace)
for i=1, 50 do
	for j=1, 50 do
		local a = Instance.new("Part")
		a.Position = Vector3.new(xoff + i * 2, 8, yoff + j * 2)
		a.Size = Vector3.new(1, 1, 1)
		a.Anchored = true
		a.Parent = folder
	end
end

task.wait(1)

while task.wait(0.1) do
	for i, v in folder:GetChildren() do
		v.Position += Vector3.new(math.random() * 0.1 - 0.05, math.random() * 0.1 - 0.05, math.random() * 0.1 - 0.05)
	end
end

(just put it in the ServerScriptService, and you’re good to go)

This is the result I got.

So, it turns out that I am, in fact, not at fault for the high outgoing traffic. I tried setting the parts’ network owner to the server using a:SetNetworkOwner(), but it turns out you cannot set the network owner of an anchored part? :sob: I also tried disabling StreamingEnabled, but that didn’t seem to help with my issue. I also tried searching for solutions on Google, but it turns out nobody even acknowledged this?

This is a real issue in my game, because, in later rounds, you can easily have over 2000 enemies updating their position a bunch of times per second, so does anyone know any workaround for this? Maybe stopping the replication to the client of the enemies altogether (that would help me with incoming bandwidth as well, since I already developed a tool to send compressed Vector3s for my use case, and it works very well). Or, has at least anyone here stumbled upon this before? I cannot be the only one, right?

In the actual game, I move all enemies with the workspace:BulkMoveTo() function, so I don’t think it’s the server giving part of its work to the clients or anything like that. And, even if it is, how do I disable that??

Either way, I hope anyone can tell me a good method to bypass this weird replication “feature”, or at least tell me why it’s happening. Thanks in advance!!

1 Like

The client echoing the changes to the server does seem like an engine bug. It does indeed happen, and I can’t see any reason why it would for assemblies the client doesn’t have ownership over (especially since they’re anchored).

You can, however, circumvent this by creating the models on the client. Running the script you provided from a LocalScript does not produce any networking traffic. With this, you’d simply send positional updates as raw data to the client and have the client apply them on its own.

If you still need server-side models for spatial queries, you can construct the the models and parent them to workspace.CurrentCamera or a WorldModel in a non-replicating container to prevent them from replicating to clients while still allowing you to perform raycasts or overlap checks or what have you.

1 Like

Hey, thanks for the response! I actually already create the models on the client whenever the enemy’s hitbox gets replicated to it, but I need the hitbox for spacial queries, as you mentioned.

To be honest, I can recall seeing the workspace.CurrentCamera method somewhere, but I didn’t actually try it until now, as some responses were saying it doesn’t work. But now that I tried it, I can say that it does, indeed, work!! I have been searching for something like this for quite a while now and have found a lot of forum entries needing this, but nobody mentioned this method, so I’m pretty surprised this isn’t common knowledge.

I also was not aware that you could have multiple WorldModels in a game, so thanks for that as well! This could have made my life wayyy easier if I knew about it earlier.

Oh also, since this is an engine bug, I will try reporting it and hope it gets fixed, so other people do not have to run into this issue.

Either way, thanks a bunch for your response, it has really helped me a lot, thanks!!

1 Like