AssemblyLinearVelocity lagging when server is large

I’m currently using AssemblyLinearVelocity to move my train in the game, but I noticed when player count goes pass 40, the AssemblyLinearVelocity begins to lag and trains are starting to move at ~10FPS

I’ve tried using LinearVelocity but the train derails very frequently, I’ve also tried using SetNetworkOwner and controlling the train on the client, but the server crashes with error 277 right after I’ve implemented the script.

Below is the code:

while wait(.1) do
	script.Parent.Cart1.Body.Floor.AssemblyLinearVelocity = script.Parent.Cart1.Body.Floor.CFrame.RightVector * (speed*1.15)
	script.Parent.Cart2.Body.Floor.AssemblyLinearVelocity = script.Parent.Cart2.Body.Floor.CFrame.RightVector * (speed*1.15)
	script.Parent.Cart3.Body.Floor.AssemblyLinearVelocity = script.Parent.Cart3.Body.Floor.CFrame.RightVector * (speed*1.15)
	script.Parent.Cart4.Body.Floor.AssemblyLinearVelocity = script.Parent.Cart4.Body.Floor.CFrame.RightVector * (speed*1.15)
	script.Parent.Cart5.Body.Floor.AssemblyLinearVelocity = script.Parent.Cart5.Body.Floor.CFrame.RightVector * (speed*1.15)
	script.Parent.Cart6.Body.Floor.AssemblyLinearVelocity = script.Parent.Cart6.Body.Floor.CFrame.RightVector * (speed*1.15)
	script.Parent.Cart7.Body.Floor.AssemblyLinearVelocity = script.Parent.Cart7.Body.Floor.CFrame.RightVector * (speed*1.15)
	script.Parent.Cart8.Body.Floor.AssemblyLinearVelocity = script.Parent.Cart8.Body.Floor.CFrame.RightVector * (speed*1.15)
end

Where speed is the speed of the train (0-80)

When testing on studio, I’ve also noticed that the train can go smooth on server side, while the train sometimes lag for ~1 second for every 10 seconds of running.

Could there be any alternatives or fixes to this? Thank you!

This is also known as Physics Throttling, Workspace | Documentation - Roblox Creator Hub, you can’t do much about it but just improve the overall performance of how parts behave, I recommend reading other topics regarding this, oh and, the snippet you provided is not exactly very friendly.
Are you sure you can’t use a friendlier connection, like when detecting speed has changed?