Tween movement or Manual movement?

Is it better to tween a position on the SERVER side or to move a parts position manually by numbers?
I have a model that works on server side and uses a lot of tweens but creates lag because it needs to replicate over to the client and such. So would it be better to just use numbers to move the object manually instead of using a tween?

ex:

local part = game.Workspace.Part

for i = 1, 5 do
  task.wait()
  part.Position = Vector3.new(0,i,0)
end

ex:

local part = game.Workspace.Part
local TweenService = game:GetService("TweenService")
local Property = {Position = Vector3.new(0,5,0)}

local Tween = TweenService :Create(part, TweenInfo.new(1), Property)
Tween:Play()

Keep in mind that these are just examples. My problem is much more complex with involving loops and multiple tweens at the same time.

Hello.

Tween movement reduces the lag and makes the action smoother. For and While loops just make the recv go high and loosen the performance.

If I were you, I would use TweenService instead of doing it manually.

1 Like

Ok so how do I tackle the problem of lag being created in my game? It starts off smooth but as the loop goes on, whenever the tweens play the place gets laggier and laggier

You’re playing the loop without any unignorable delay, seemingly. Task.wait() itself can’t handle all the tough stuff especially if you’re running these loops on multiple scripts.

Running one tween for one part is enough by itself, or if you wish to run your tweens for multiple parts you will have to create a model and loop through every part in it to create separate tweens for them.

This is quite false, tween are actually very resource intensive. You are better of doing for loops, but you also can just tween objects on the client through remotes which the client excels at compared to the server. @billybobtijoseph

Tweens are only performance disruptive if you’re using it too much, and loops just make the RECV higher. But I believe you’re right on the Client-Side Rendering part. You can follow the object info on the server by creating a table and assigning the object to it, and sending remotes to update the position on the client every 0.1 seconds. (Or 10 heartbeats).

Any examples I can get? I am using about maybe 30 tweens running around the same time. I have a lot of models that need it. So should I still stick to the tweens or perhaps go for loops?

Try them both and turn Performance Stats on, calculate the recv and tell me. It is really late here so I will be sleeping really soon. Will check that out next morning, bye!

local objectTable = {
      ["ExampleObject"] = {
["Name"] = "Part",
      }
}

local count = 0
game:GetService("RunService").Heartbeat:Connect(function()
count += 1

if count == 10 then
for _, obj in pairs(objectTable) do
game.ReplicatedStorage.Remotes.Render:FireAllClients(obj)
end

end)

You also will be creating the object on the client if there isn’t any objects on the client.

P.S: I wrote this code in DevForum. There may be typos and the code may be untidied.