Character rotates while mouse locked

I think this can help, I got this code from another article that I read before.

Article: How to Force Enable Shift-Lock (Without changing the PlayerModule)

local _, y = workspace.CurrentCamera.CFrame.Rotation:ToEulerAnglesYXZ() --Get the angles of the camera
root.CFrame = CFrame.new(root.Position) * CFrame.Angles(0,y,0) --Set the root part to the camera's rotation