I'm trying to recreate shift lock in my custom camera, but im trash at anything that requires math or cframes. I've had a go and I know I need to use lockcenter on the mouse and use userinputservice to check where the mouse is moving, but the camera is messed up. How would I modify this to make it work?
-- Scripted by LifeInDevelopment local userInputService = game:GetService('UserInputService') local player = game.Players.LocalPlayer local character = player.CharacterAdded:wait() local mouse = player:GetMouse() local camera = workspace.CurrentCamera local torsoOffset = CFrame.new(0, 3, -5) local maxSensitivity = 10 local xSensitivity = 5 -- max is 10 local ySensitivity = 5 userInputService.MouseBehavior = Enum.MouseBehavior.LockCenter userInputService.InputChanged:connect(function(inputObject) local character = player.Character local torso = character:FindFirstChild('Torso') or character:FindFirstChild('UpperTorso') if inputObject.UserInputType == Enum.UserInputType.MouseMovement then local deltaX, deltaY = inputObject.Delta.x * (xSensitivity/maxSensitivity) , inputObject.Delta.y * (ySensitivity/maxSensitivity) camera.CFrame = torso.CFrame * torsoOffset * CFrame.Angles(deltaX, 0, 0) * CFrame.Angles(0, deltaY, 0) end end)