Alright, so what's happening is I'm working on a third person camera system, but I am have a lot of trouble here with the torso. It works fine when you test, right up until you walk into a wall or something. The torso will rotate and it gets stuck there. I have been trying to find a solution for the past 2 days and nothing has come out of it. To test, just make a local script and paste code in there.
repeat wait() until game.Players.LocalPlayer.Character --// Variables local player = game.Players.LocalPlayer local char = player.Character local valueFolder = char:WaitForChild('Values') local mouse = player:GetMouse() local humanoid = char:WaitForChild("Humanoid") local rootPart = char:WaitForChild("HumanoidRootPart") humanoid.AutoRotate = false local switched = false; --// Tables local control = { cam = workspace.CurrentCamera; camOffset = Vector3.new(2, 2, 8); cameraAngleX = 0; cameraAngleY = 0; xDelta = valueFolder:WaitForChild('xDelta'); yDelta = valueFolder:WaitForChild('yDelta'); } --// Services local ContextActionService = game:GetService("ContextActionService") local uis = game:GetService("UserInputService") local RunService = game:GetService("RunService") local ts = game:GetService('TweenService') --// Functions local function playerInput(inputObject) control.cameraAngleX = control.cameraAngleX - inputObject.Delta.X -- Reduce vertical mouse/touch sensitivity and clamp vertical axis control.cameraAngleY = math.clamp(control.cameraAngleY-inputObject.Delta.Y*0.4, -75, 75) -- Rotate root part CFrame by X delta --inputObject.Delta.X rootPart.CFrame = rootPart.CFrame * CFrame.Angles(0, math.rad(-inputObject.Delta.X), 0) end local function focusControl(inputObject) uis.MouseBehavior = Enum.MouseBehavior.LockCenter uis.MouseIconEnabled = false end --// Inputs uis.InputBegan:connect(function(input,chat) if not chat then if input.UserInputType == Enum.UserInputType.MouseButton1 then focusControl(input) end; if input.KeyCode == Enum.KeyCode.V then switched = not switched if not switched then control.camOffset = Vector3.new(2, 2, 8) else control.camOffset = Vector3.new(-2, 2, 8) end; end; end end) uis.InputChanged:connect(function(input,chat) if not chat then if input.UserInputType == Enum.UserInputType.MouseMovement then playerInput(input) end; end end) --// Renders RunService.RenderStepped:Connect(function() if control.cam.CameraType ~= Enum.CameraType.Scriptable then control.cam.CameraType = Enum.CameraType.Scriptable end local startCFrame = CFrame.new((rootPart.CFrame.Position)) * CFrame.Angles(0, math.rad(control.cameraAngleX), 0) * CFrame.Angles(math.rad(control.cameraAngleY), 0, 0) local cameraCFrame = startCFrame:ToWorldSpace(CFrame.new(control.camOffset.X, control.camOffset.Y, control.camOffset.Z)) local cameraFocus = startCFrame:ToWorldSpace(CFrame.new(control.camOffset.X, control.camOffset.Y, -10000)) control.cam.CFrame = CFrame.new(cameraCFrame.Position, cameraFocus.Position) local newNeck = char:WaitForChild('Torso'):WaitForChild('Neck') local HRPCF = char:WaitForChild("HumanoidRootPart").CFrame * CFrame.new(0, 1.5, 0) * CFrame.new(char:WaitForChild("Humanoid").CameraOffset) newNeck.C0 = newNeck.C0:lerp(char:WaitForChild("HumanoidRootPart").CFrame:toObjectSpace(HRPCF) * CFrame.Angles(math.asin((mouse.Hit.p - mouse.Origin.p).unit.y),0,0),0.2) newNeck.C1 = newNeck.C1:lerp(CFrame.new(), 0.2) end)