Draggable Camera Around 3D Point

I Need A Script That

Positions and Rotates the Camera in a Sphere-Like Pattern around a specified 3D Point.

The White Cube in the Middle represents a specified 3D Point somewhere in the World. The Red Sphere and the Cameras around it showcase the full range of motion that the Camera has.

Core Idea:

-- Services
local UserInputService = game:GetService('UserInputService')
local RunService = game:GetService('RunService')

-- Variables
local Dragging = false
local LastPosition
local Camera = workspace.CurrentCamera

-- Camera Settings
local Distance = 5
local Sensitivity = 0.02
local CenterPoint = Vector3.new(0,0,0)
Camera.CameraType = Enum.CameraType.Scriptable

-- Camera Update
local function UpdateCamera(Delta)
-- Calculate Camera Position here
end

-- Cursor Dragging
UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed then return end
    if input.UserInputType == Enum.UserInputType.MouseButton2 then
        Dragging = true
        LastPosition = input.Position
    end
end)

UserInputService.InputEnded:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton2 then
        Dragging = false
    end
end)

UserInputService.InputChanged:Connect(function(input)
	if Dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
		local Delta = input.Position - LastPosition
		UpdateCamera(Delta)
		LastPosition = input.Position
	end
end)

If you have any Questions, Ideas or Solutions, write a comment!

The simplest way is to just have the camera adjust in any way the user wants, and then after, use the following:

Camera.CFrame = CFrame.lookAt(CameraPosition, Target)

If you want to constrain it to a certain distance, you may be able to use something like:

Camera.CFrame = CFrame.lookAt(TargetPosition + (CameraPosition - Target).Unit * 20, Target)