Tweens using too much bandwidth

On the server I’m tweening 72 Vector3Values to a different value at the same time. But it uses over 100 kb/s for this alone. Is there a more optimized way to slowly change the value of a vector3 to a different vector3?

image
(only thing running is the script above)

1 Like

Never use the server to do anything visual. Ideally, the server should only deal with client-server communication and secure data. Instead, use remotes to tell clients when to use certain animations/tweens or what to update to.

2 Likes

This is the correct answer.

@strangefancypants Almost everything visually related should be done on the client so that you don’t have problems with bad UX or lag.

Its not Visual
image

Its tweens the Position of where the army actually is on the server to Destination.Value
And on the client it tweens the Armies model to the Position

Tweening is still not a great option. You could use a loop to update it as the position event no longer works, but this can still be intensive. Also, you should be using Attributes instead of values. They’re faster and load instantly (no need to use WaitForChild).

I’m not using attributes for this because they take longer to be called on. Usually I use attributes for something I rarely call on instead.

Attributes are faster to be called on though. They’re meant to replace values entirely (except for ObjectValue for some reason).

1 Like
local st = os.clock()
for i = 1,50000 do
local se = workspace.StreamingEnabled
end
local en = os.clock()
print((en-st)*1000)

local st = os.clock()
for i = 1,50000 do
local se = workspace:GetAttribute('StreamingEnabled')
end
local en = os.clock()
print((en-st)*1000)

Test it out for yourself

Also I’m still looking for a better option than tweening all these Positions to their Destination because it uses up too much bandwidth

I’ve already done my own test right now and they have the same read/write speed. But attributes always load faster.

Also why not use Humanoid:MoveTo() and then just updating its position with a loop?

I’m using custom NPCs that arent humanoids, and Humanoid:MoveTo() is too performance heavy for my end goals, (400 NPC’s moving around with little to no lag)

The only other option I can think of off the top of my head is to only update goals then. Have a delay for how long you expect it to take to reach the goal, then change the goal after that. Each time the goal is updated, the client can take over on its end. You can also store the time at which the goal started in order to update clients that join or update late.

The main difference between value objects and attributes is that attributes are guaranteed (by Roblox) to replicate the following frame.

1 Like