Tweens Jittering While Ran On Client

I’m very new to CFrame and Tweening, but I am trying to move a roller coaster car around the track using TweenService. It Tweens the car between each numbered node. I tried running the Tween on the server(Script in workspace), but it lags in a live server.

I then tried to run the Tween on the client(LocalScript in ReplicatedFirst). The car starts to jitter constantly (not lag every so often) a lot. I’ve done hours of looking for solutions, but have not found that anyone has had the same issue.

Ran on Server:
https://gyazo.com/71b6fc5429eae34abd9242a2da7b36d4

Ran on Client:
https://gyazo.com/1402f8af27c322fc072f9bdef101c849

Here is the code in the LocalScript:

wait(5)

local WaitValue = script.WaitTime --NumberValue inside the script
local TrackCount = 0

--Name all nodes
for i, v in pairs(game.Workspace["Compiled New Roller Coaster"]:GetChildren()) do
	TrackCount = TrackCount + 1
	v.Name = tostring(TrackCount)
end

local TweenService = game:GetService("TweenService")
local Train = game.Workspace.Train

wait(1)

local CurrentTrack1 = 0

while true do

	CurrentTrack1 = CurrentTrack1 + 1
	local Info = TweenInfo.new(
		WaitValue.Value,
		Enum.EasingStyle.Linear,
		Enum.EasingDirection.Out,
		0,
		false,
		0	
	)
	
	local Goals = {CFrame = game.Workspace["Compiled New Roller Coaster"][CurrentTrack1].CFrame} 
	local Tween1 = TweenService:Create(Train, Info, Goals)
	Tween1:Play()
	if CurrentTrack1 == TrackCount then
		CurrentTrack1 = 0		
	end
	Tween1.Completed:Wait()
end		

If you guys need any more info, just let me know and I’ll be happy to provide.

Edit: The WaitValue is set at .9

Edit2: I thought the jittering only happened on the client when I was sitting in the seat, but I looked closer and it happens even when I’m not sitting in the seat.

Here is a better look at the jittering while I’m sitting in the seat and the tweens are being ran on the client:

https://gyazo.com/1d24def2ab6a03542c10935e1f524809

You can try Network Ownership

Edit: Maybe not. I think that’s focused more for normal Roblox physics stuff. I think maybe using remotes to communicate to all clients the settings for the tween and running them there?..

Uh, I don’t think I’m giving sound advice here. You can maybe look at some of this stuff, but I don’t know if it’s a solution or really anything helpful. Sorry! Kind of tired, probably gonna call it a night now.

Have you tried running it without the player on it?

Yes, it will run very smoothly while ran on the client until I sit in the seat.Thank you for your reply!

https://gyazo.com/8db724a17c8cc9d0f7ceed6dd128ab89

EDIT: I looked closer and the car actually jitters on the client Without anyone sitting in the seat.

https://gyazo.com/1402f8af27c322fc072f9bdef101c849

After a fix has been made to the jittering, I think I am going to have to use remotes to make sure that the car is synced for everyone in the game some time in the future. Thank you!

Anchor the car. If you anchor the object, network replication for physics is simply disabled. It will then be smooth for clients. If you want the car to not be anchored and utilize Roblox physics, do not use CFrame in order to move your car.

I sadly can’t say that it is as easy as checking the “anchored” box :disappointed:. The car is anchored and the seat is welded to the car using a WeldConstraint. I thought that maybe the Weld could be the issue, so I Anchored the seat as well and tweened both at the same time. Same jittery result as soon as I sat in the seat sadly. Thank you for the reply!

https://gyazo.com/12199b93995e66a5e74b5ea7242415cd

You can group the entire car assembly as a single model. Anchor all parts in this model. Then, utilize SetPrimaryPartCFrame to move your model. This will translate the primary part of the model, and all additional parts in the model will move relative as well.

Thank you for your reply! I tried setting the PrimaryPartCFrame, but had some really weird results:

https://gyazo.com/e9871eec77fa68366e15922ee2de1c7d

An update on the issue:

I’m very sorry if I’m making this topic linger.

I decided to see what would happen if I try to make a bare bones Tween on the client. Even after that it would not tween smoothly for some reason. If you spot any errors with my code, please let me know. Thank you!

local TweenService = game:GetService("TweenService")

local Car = game.Workspace:WaitForChild("Car")
local Target = game.Workspace:WaitForChild("Target")

local TSInfo = TweenInfo.new(
2.5,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)

local Goal = {CFrame = Target.CFrame}
local Tween = TweenService:Create(Car, TSInfo, Goal)

-- wait for character to load in to see tween
wait(6)
Tween:Play()

GIF of jittery tweening

https://gyazo.com/89361b82fd429052f2d97cc41bcaf86a

Screenshot of Explorer

https://gyazo.com/844564f9a60b035d1deb42912d9578b7

Both the Car and Target are anchored.

I ended up using :Lerp() instead of TweenService to get the desired results. Thank you all for your time and help!

Here is my code (this includes syncing for all clients):

Server-Side
local RS = game:GetService("ReplicatedStorage")
local RE = RS:WaitForChild("TestingCoaster")

local Train = game.Workspace:WaitForChild("Train")
local Speed = script.Speed

local CT1 = 1
local CT2 = 0


local C1SP = Train.Car1.CFrame 
local C2SP = Train.Car2.CFrame


wait(7)
while true do
	CT1 = CT1 + 1 
	CT2 = CT2 + 1
	
	for i = 0,1,.3 do

		RE:FireAllClients(Train, C1SP, C2SP, CT1, CT2, i)
		wait()
	end
	C1SP = game.Workspace["Compiled New Roller Coaster"][CT1].CFrame
	C2SP = game.Workspace["Compiled New Roller Coaster"][CT2].CFrame

	if CT1 == 190 then 
		CT1 = 1
		CT2 = 0
	end
	game:GetService("RunService").Stepped:Wait()

end
Client-Side
local RS = game:GetService("ReplicatedStorage")
local RE = RS:WaitForChild("TestingCoaster")
local NodesModel = game.Workspace:WaitForChild("Compiled New Roller Coaster")



RE.OnClientEvent:Connect(function(Train, C1SP, C2SP, CT1, CT2, i)
		Train.Car1.CFrame = C1SP:Lerp(NodesModel[CT1].CFrame, i)
		Train.Car2.CFrame = C2SP:Lerp(NodesModel[CT2].CFrame, i)
end)

I think I need to use tables to clean up my event parameters at some point.