Player rotating whilst jumping

I have a script that moves the player relative to another part. It’s basically like when a player is standing on a part and they move with it, but it works even if they’re not standing on it. I wanted the camera to work like shift lock does except still keep the player rotating relative to the part, which it doesn’t do usually. I edited the existing camera scripts, specifically the attach camera type, and got it working as I wanted, however when a player jumps and moves to the side, they rotate instead of simply moving left or right. I’ve been looking through the movement scripts but I’m pretty sure the issue is in the attach camera type itself as that’s also what happens on the unedited attach camera type script.

This is the code, all I changed was adding the camera yaw variable:

elseif self.cameraType == Enum.CameraType.Attach then
		local subjectCFrame = self:GetSubjectCFrame()
		local cameraPitch = camera.CFrame:ToEulerAnglesYXZ()
		local cameraYaw = CameraInput.getRotation().X
		local _, subjectYaw = subjectCFrame:ToEulerAnglesYXZ()

		cameraPitch = math.clamp(cameraPitch - CameraInput.getRotation().Y, -PITCH_LIMIT, PITCH_LIMIT)

		newCameraFocus = CFrame.new(subjectCFrame.p)*CFrame.fromEulerAnglesYXZ(cameraPitch, subjectYaw - cameraYaw, 0)
		newCameraCFrame = newCameraFocus*CFrame.new(0, 0, self:StepZoom())

Any tips would be very helpful!

Does it have anything to do with Humanoid.AutoRotate? In case you don’t know, if Humanoid.AutoRotate is set to false the character orientation stays the same, even when u jump, walk around and all of that.