i’m using this local script for the player so he will face the same direction the camera looks (like using shift lock), and the player can press a button to freely move his camera, but it appears that sometimes when the player changes camera modes, the character’s normals invert. I know this is caused by an invalid rotation matrix, but i’m using the camera’s rotation matrix on the player, and for some reason sometimes the camera has a negative rotation matrix, causing this to happen:

also, if i grab the absolute value of every element of the rotation matrix, the camera just doesn’t work properly

btw here is the code i’m using:

```
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
local rootPart = character:WaitForChild("HumanoidRootPart")
local cameraAngleX = 7.5
local cameraAngleY = 0
local function playerInput(actionName, inputState, inputObject)
if _G.laserActive == true then
if inputState == Enum.UserInputState.Change then
cameraAngleX = cameraAngleX - inputObject.Delta.X
cameraAngleY = math.clamp(cameraAngleY-inputObject.Delta.Y*0.4, -75, 75)
rootPart.CFrame = rootPart.CFrame * CFrame.Angles(0, math.rad(-inputObject.Delta.X), 0)
end
end
end
ContextActionService:BindAction("PlayerInput", playerInput, false, Enum.UserInputType.MouseMovement, Enum.UserInputType.Touch)
RunService.RenderStepped:Connect(function()
if _G.laserActive2 == true and _G.delay == false then
humanoid.AutoRotate = false
if camera.CameraType ~= Enum.CameraType.Scriptable then
camera.CameraType = Enum.CameraType.Scriptable
end
local startCFrame = CFrame.new((rootPart.CFrame.Position)) * CFrame.Angles(0, math.rad(cameraAngleX), 0) * CFrame.Angles(math.rad(cameraAngleY), 0, 0)
local cameraCFrame = startCFrame:ToWorldSpace(CFrame.new(cameraOffset.X, cameraOffset.Y, cameraOffset.Z))
local cameraFocus = startCFrame:ToWorldSpace(CFrame.new(cameraOffset.X, cameraOffset.Y, -10000))
camera.CFrame = CFrame.new(cameraCFrame.Position, cameraFocus.Position)
local xVector = camera.CFrame.XVector * Vector3.new(2,1,1)
rootPart.CFrame = rootPart.CFrame:Lerp(CFrame.fromMatrix(rootPart.CFrame.Position,camera.CFrame.XVector, rootPart.CFrame.YVector, rootPart.CFrame.ZVector),1)
elseif _G.laserActive2 == false and _G.delay == false then
if camera.CameraType ~= Enum.CameraType.Track then
camera.CameraType = Enum.CameraType.Track
end
humanoid.AutoRotate = true
local startCFrame = CFrame.new((rootPart.CFrame.Position)) * CFrame.Angles(0, math.rad(cameraAngleX), 0) * CFrame.Angles(math.rad(cameraAngleY), 0, 0)
elseif _G.delay == true then
if camera.CameraType ~= Enum.CameraType.Attach then
camera.CameraType = Enum.CameraType.Attach
end
humanoid.AutoRotate = false
print(camera.CFrame.XVector)
print(camera.CFrame.YVector)
print(camera.CFrame.ZVector)
end
end)
end)
```