Welding to CFrame Tilting Model

The train in the picture is weldconstrainted to the red part (every part is unanchored). The train slowly tilts as the train turns the bends.

I don’t know why this is happening, here’s the code:

local function Update()
	for i,v in pairs(rightmotors) do
		v.AngularVelocity = vel
	end
	for i,v in pairs(leftmotors) do
		v.AngularVelocity = -vel
	end
	for i,v in pairs(mains) do
		v.Orientation = Vector3.new(v.Orientation.X,v.Orientation.Y,0)
		v.AssemblyLinearVelocity = v.AssemblyLinearVelocity.Unit * vel
		v.AssemblyLinearVelocity = Vector3.new(v.AssemblyLinearVelocity.X,-1,v.AssemblyLinearVelocity.Z)
	end
	for i,v in pairs(cars) do
		TS:Create(v.Build.Main,info,{CFrame = v.Chassis.WheelSetFront.Connector.CFrame:Lerp(v.Chassis.WheelSetBack.Connector.CFrame,0.5)}):Play()
		--v.Build.Main.CFrame = v.Chassis.WheelSetFront.Connector.CFrame:Lerp(v.Chassis.WheelSetBack.Connector.CFrame,0.5)
	end
end

Please help!

Don’t worry I fixed it, Solution:
I was updating the orientation of the wrong parts, which were not the ones the CFrame was being attached to. After rewriting the code slightly it works fine.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.