Some really weird behavior with hingeconstraints and player welds?

Hello, I’m currently scripting a cannon. The player uses the cannon by clicking on a part, then getting welded to another part and a LocalScript is given to them with control interface. The whole mechanisms of the cannon are based off of Welds, HingeConstraints and Attachments.
I get some strange behavior sometimes whenever I attempt using the cannon. Video below.
In the first half, the cannon moves according to the direction that the humanoid is facing. Usually, the cannon would be turned with WASD but here using WASD doesn’t even work; the player controls the turning. After the player would “leave” the cannon he’d get flung.
In the second half, the cannon moves normally. WASD to move, doesn’t move according to the humanoid.

I have practically zero idea of what the heck is going on here, if you need more code or details by all means please LMK and I’ll provide it for you. If someone could figure out what’s going on that would be great!

Is the cannon being rotated because the player is “pushing” it or do you have your own WASD controls that are rotating it?

Supposedly, I have controls to rotate the cannon. The LocalScript fires remote events to a Script inside the cannon, and that script changes hingeconstraint velocities. I don’t know if the player is supposedly pushing it or not, unless they have player control over the cannon? No clue

Normally this works 9/10 of the time, but for 1/10 this happens.

Mind sharing the script that’s modifying the HingeConstraints? Also the portion when the player “detaches” from the cannon?

function CannonHandler.ChangeAimRequested(player, Cannon, AimDirection)
	local Occupant = Cannon.Values.Occupant
	local CannonRootHinge = Cannon.Chassis.CannonRoot.RootHinge
	local ElevationRootHinge = Cannon.ElevatedParts.ElevationRoot.ElevationHinge
	local WheelAxle = Cannon.Chassis.WheelAxle
	local LeftWheelHinge = WheelAxle.LeftWheelHinge
	local RightWheelHinge = WheelAxle.RightWheelHinge
	local ShaftSlider = Cannon.Chassis.ElevationShaft.CannonSlider
	if player == Occupant.Value then
		if AimDirection == "Left" then
			CannonRootHinge.AngularVelocity = 0.4
			LeftWheelHinge.AngularVelocity = -0.8
			RightWheelHinge.AngularVelocity = 0.8
		if AimDirection == "Right" then
			CannonRootHinge.AngularVelocity = -0.4
			LeftWheelHinge.AngularVelocity = 0.8
			RightWheelHinge.AngularVelocity = -0.8
		if AimDirection == "Up" then
			ElevationRootHinge.AngularVelocity = 0.1
			ShaftSlider.AngularVelocity = 3
		if AimDirection == "Down" then
			ElevationRootHinge.AngularVelocity = -0.1
			ShaftSlider.AngularVelocity = -3
		if AimDirection == "StopRotation" then
			CannonRootHinge.AngularVelocity = 0
			LeftWheelHinge.AngularVelocity = 0
			RightWheelHinge.AngularVelocity = 0
		if AimDirection == "StopElevation" then
			ElevationRootHinge.AngularVelocity = 0
			ShaftSlider.AngularVelocity = 0
function CannonHandler.SeatLeave(player, Cannon)
	local SitPart = Cannon.Chassis.SitPart
	local Weld = SitPart:FindFirstChild("PlayerWeld")
	if not Weld then return end
	Cannon.Chassis.CannonRoot.Anchored = false
	Cannon.Chassis.RearChassis.CanCollide = true
	Cannon.Chassis.CentralChassis.CanCollide = true
	Cannon.Wheels.LeftWheel.CanCollide = true
	Cannon.Wheels.RightWheel.CanCollide = true
	--literally everything else
	Cannon.Values.Occupant.Value = nil
	if not Cannon.Chassis.CannonRoot.Anchored then
	Cannon.Chassis.WheelAxle.LeftWheelHinge.ActuatorType = Enum.ActuatorType.None	
	Cannon.Chassis.WheelAxle.RightWheelHinge.ActuatorType = Enum.ActuatorType.None

Could it be network ownership? Like the player is somehow controlling the assembly and not the hingeconstraints?

Nevermind, found the problem.

The problem was that the weld incorporated the SitPart and the HumanoidRootPart as its Part0 and Part1; apparently when I changed the HumRootPart to Torso it fixed.

No, nevermind the problem is still here. Arrrgh what’s going on!??