Weird behaviour in trains, when players are seated in it

VIDEO of said behaviour

For some context, the seats are welded to the train using WeldConstraints

The train uses vectorForces to move, and when the train touches a certain part, it stops. To stop, it uses this script:

local AllSeat = {}
for _,s in pairs(script.Parent.Parent:GetDescendants()) do
	if s:IsA("Seat") then
		table.insert(AllSeat, s)
	end
end

local PlayerModel = {}

local function Stop(Station)

	table.clear(PlayerModel)
	for _,s in pairs(AllSeat) do
		if s.Occupant ~= nil then
			table.insert(PlayerModel, s.Occupant.Parent)
		end
	end

	Train.PrimaryPart.AssemblyLinearVelocity = Vector3.new()
	for _,s in pairs(PlayerModel) do
		s.PrimaryPart.AssemblyLinearVelocity = Vector3.new()
	end

end

I am simply just setting their Velocities to zero.

However, there is a slightly change in behavior in the train stopping mechanism when a player is seated in the train. It somehow teleports and overshoots the doors by a slight margin
When no players are seated in the train, it stops exactly where it should be, where the doors are aligned.

Anyone has any theories on how this could happen?

Ah. Interesting. Sounds like some roblox phys shenanigans..I would like to recommend this:

  1. Disable the Weld constraint: When the train is halting, try disabling the Weld constraint between the players’ characters and the seats. This might prevent the small jump in the train’s position.
    Try this, see if it works, if not try this;
  2. Use a different type of constraint: Instead of using a Weld constraint, try using a Motor6D constraint to attach the players’ characters to the seats. This could provide a more stable and consistent attachment.
  3. Adjust the train’s physics: Maybe if you try adjusting the train’s physics settings, you could see if that resolves the issue. You might wanna tweak the train’s mass, friction, or other properties to get it to behave correctly. Sometimes messing around with stuff may just fix it altogether. Lmao. I do that
    One important thing I will say is:

Check for other scripts or plugins: Make sure that there aren’t any other scripts or plugins that might be interfering with the train’s physics. Sometimes, other scripts can cause unexpected behavior when they interact with the game’s physics.


Please let me know if any of these above will help. I hope it finds your liking! feel free to ask if you need any other tips.