Shoulder view camera making people spin

What the title says. Here’s a video that showcases the issue (The issue happens when I turn on Shoulder camera or when the game starts with the value turned on) :

And here’s the explorer + scripts:
image

ShoulderCamHandler:

local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer

local camera = workspace.CurrentCamera



game:GetService("RunService").RenderStepped:Connect(function()

	if game.ReplicatedStorage.StuffValues.ShoulderCam.Value == true then
		
		camera.CameraType = Enum.CameraType.Scriptable


		local char = script.Parent

		local humanoid = char:WaitForChild("Humanoid")
		humanoid.AutoRotate = false

		local hrp = char:WaitForChild("HumanoidRootPart")


		local x = 0
		local y = 0


		local offset = Vector3.new(3, 3, 10)
		
		player.CameraMaxZoomDistance = 90
		player.CameraMinZoomDistance = 90
		
		

		uis.InputChanged:Connect(function(input, processed)

			if processed then return end

			if input.UserInputType == Enum.UserInputType.MouseMovement then

				x = x - input.Delta.X

				y = math.clamp(y - input.Delta.Y*0.4, -75, 75)


				hrp.CFrame = hrp.CFrame * CFrame.Angles(0, math.rad(-input.Delta.X), 0)
			end
		end)
		
		uis.MouseBehavior = Enum.MouseBehavior.LockCenter


		local startCFrame = CFrame.new((hrp.CFrame.Position)) * CFrame.Angles(0, math.rad(x), 0) * CFrame.Angles(math.rad(y), 0, 0)
		local cameraCFrame = startCFrame:ToWorldSpace(CFrame.new(offset.X, offset.Y, offset.Z))
		local cameraDirection = startCFrame:ToWorldSpace(CFrame.new(offset.X, offset.Y, -10000))

		camera.CFrame = CFrame.new(cameraCFrame.Position, cameraDirection.Position)
		
		
		
		
	elseif game.ReplicatedStorage.StuffValues.ShoulderCam.Value == false then
		
		local humanoid = player.Character:WaitForChild("Humanoid")
		humanoid.AutoRotate = true
		
		uis.MouseBehavior = Enum.MouseBehavior.Default
		
		player.CameraMaxZoomDistance = 20
		player.CameraMinZoomDistance = 10
		
		
		camera.CameraType = Enum.CameraType.Custom

	end
	
	
end)

Any help appreciated!

i mean this is clearly fully random.
You can probably just do this

local lookVec = Vector3.new(camera.CFrame.LookVector.X,hrp.CFrame.LookVector.Y,camera.CFrame.LookVecor.Z)
hrp.CFrame = CFrame.new(hrp.Postion,hrp.Position + lookVec)

The player no longer spins, but now the character appears in the direction they were before turning on the side view camera (example if i’m looking to the left, it stays on the left when turning on the camera like this:)

(Also I want to note that I need the camera to always stay behind the player, and when the player rotates, the camera also rotates and stays behind them etc, + when moving the camera around instead of just rotating the camera it also rotates the player’s character so the character is always in front of the camera, sorry i’m pretty bad at explaining)

Yea i get what you are doing, I’ve done that before.
Make sure the lookVec is inside a loop.


Yep, it is

it updates when the mouse move, use this instead

camera:GetPropertyChangedSignal("CFrame"):Connnect(function()
    local lookVec = Vector3.new(camera.CFrame.LookVector.X,hrp.CFrame.LookVector.Y,camera.CFrame.LookVecor.Z)
    hrp.CFrame = CFrame.new(hrp.Postion,hrp.Position + lookVec)
end)