How to make a draggable viewport frame?

how do i make a draggable character viewport similar to the one in minecraft? in minecrafts inventory you can rotate your character using your mouse, im making a inventory system and i want to make my viewport draggable like that too. heres my code

-- Get references to the necessary objects
local vpf = script.Parent:WaitForChild("Character")
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()

-- Ensure the character is archivable
char.Archivable = true

-- Create and set up the camera
local cam = Instance.new("Camera")
cam.Parent = vpf
vpf.CurrentCamera = cam

-- Variable to hold the cloned character
local clonedChar

-- Function to clone the character and update the camera
local function updateCharacterAndCamera()
	-- Destroy the previous clone if it exists
	if clonedChar then 
		clonedChar:Destroy() 
	end

	-- Clone the current character
	clonedChar = char:Clone()

	-- Get the HumanoidRootPart of the cloned character
	local hrp = clonedChar:WaitForChild("HumanoidRootPart")

	-- Update the camera's position and orientation
	cam.CFrame = CFrame.new(hrp.Position + (hrp.CFrame.LookVector * 7.5), hrp.Position)

	-- Parent the cloned character to the viewport frame
	clonedChar.Parent = vpf
end

-- Connect the update function to the RenderStepped event
game:GetService("RunService").RenderStepped:Connect(updateCharacterAndCamera)