MoveTo vs TweenSerivce

Hi there, I’ve currently got cars spawning every second, with about 20ish cars in the game at a time. Currently they are all controlled by the TweenService handler I’ve made. I’m encountering an issue where mobile performance goes down a lot with the cars enabled ingame. When the cars are turned off, they have no issues.

local function moveCar(newCar, endPoint)
		local tweenserivce = game:GetService("TweenService")
		
		local tweeninfo = TweenInfo.new(
			9.5,
			Enum.EasingStyle.Linear,
			Enum.EasingDirection.In,
			0,
			false,
			0
		)
		
		local CFrameValue = Instance.new("CFrameValue")
		CFrameValue.Value = newCar:GetPrimaryPartCFrame()
		
		CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
			newCar:SetPrimaryPartCFrame(CFrameValue.value)
		end)
		
		local tween = tweenserivce:Create(CFrameValue, tweeninfo, {Value = endPoint.CFrame})
		tween:Play()
		
	end

Here’s a short clip:

Would having the models welded together, and using a MoveTo function cause better performance for the client?

2 Likes

Might be a neat idea to try BulkMoveTo()

Make sure to also do the moving on the client.

Effects on client
Verification on server.

1 Like

Infact, most likely they would probably go up. If performance is really an issue you should run the tweens on the clients and have a setting for the clients to pause it.

1 Like

I recommend experimenting to find out which runs better, also,

While this may be true, it’d take a longer time to set up imo.

1 Like

Yeah, I’ve noticed an increase in performance since I switched the animation of the cars to the client side. Just need to figure out how I’m going to handle the rest on the server side. Thank you!

You shouldn’t use :SetPrimaryPartCFrame(), this function has been ‘deprecated’. You should use :PivotTo(). The reason is because :SetPrimaryPartCFrame() has float point errors once you use it a certain degree.

Thank you, I’ve changed it. However, does it only matter if the object is about 100,000 studs away from the player?

1 Like

Regardless of where the object is, :SetPrimaryPartCFrame() will always have float point problems. You might be getting confused with the nil/null zone after ~10,000 studs.

Edit:

:SetPrimaryPartCFrame() (After 10,000 usages ):

:PivotTo() (After 10,000 usages ):

You can see the gap in the red model. While the blue model doesn’t have a single problem.