Having difficulty adding throwing to my custom Drag script

I am coding a custom “Dragging” system that allows you to pickup objects, rotate them, move them etc…, This is all within First Person.

After a while I was able to calculate the force of a spin, now im just having trouble applying that to the dragged part or “DragTarget” specifically with direction, as it is it seems to only apply the force to the direction in which you look, rather than the direction you span.

Here is the code, If there is any more information you need just ask, thank you.

--[[Dragging]]
local MaxDistance = 10
local HoldDistance = 6.5
local CanCollide = true
local DragConnection
local DragTarget
local DragOrient
--
local CCamera = workspace.CurrentCamera
local LastCFrame = CCamera.CFrame
local CurrentCFrame
local Axis, Angle
local RotationSpeed

--// When Button1Down Start Dragging
Mouse.Button1Down:Connect(function()
	if Mouse.Target ~= nil then
		--// Loop Locals
		DragTarget = Mouse.Target
		DragOrient = DragTarget.Orientation

		--// Check Target can be dragged
		if string.match(Mouse.Target.Name, "%[D%]") and (HRP.Position - DragTarget.Position).Magnitude < MaxDistance then 
			IsButton1Down = true
			
			--// Play Sound
			script.Drag_Start:Play()
			
			--// Update Single Set Info
			Mouse.Target.CanCollide = CanCollide
		end

		--// While Button1Down is true, loop
		DragConnection = game:GetService("RunService").RenderStepped:Connect(function()
			if IsButton1Down == true then

				--// Drag Target
				local MouseRay = Mouse.UnitRay
				local Offset = MouseRay.Direction * HoldDistance
				local TargetPosition = MouseRay.Origin + Offset
				DragTarget.Position = TargetPosition
				
				--// Prevent Velocity Movement
				DragTarget.AssemblyLinearVelocity = Vector3.new(0,0,0)
				DragTarget.AssemblyAngularVelocity = Vector3.new(0,0,0)
				DragTarget.Orientation = DragOrient
				
				--// Calculate Drop Velocity
				CurrentCFrame = CCamera.CFrame
				Axis, Angle = (CurrentCFrame * LastCFrame:Inverse()):ToAxisAngle()
				RotationSpeed = Angle / game:GetService("RunService").RenderStepped:Wait()
				LastCFrame = CurrentCFrame
				--print(RotationSpeed .. " Rad/s")

				--// If Distance is past Max then end Loop
				if (Player.Character.HumanoidRootPart.Position - DragTarget.Position).Magnitude > MaxDistance then
					IsButton1Down = false
					--
					if DragConnection then
						DragConnection:Disconnect()
						--// Play Sound
						script.Drag_End:Play()
						
						--// Update Single Set Info
						Mouse.Target.CanCollide = true
					end
				end
			end
		end)
	end
end)

--// When Button1Up Stop Dragging
Mouse.Button1Up:Connect(function()
	if IsButton1Down == true then
		--// Play Sound
		script.Drag_End:Play()

		--// Update Single Set Info
		DragTarget.CanCollide = true

		--// Apply Drop Velocity
		DragTarget:ApplyImpulse(Mouse.UnitRay.Direction * RotationSpeed * DragTarget.Mass * 2)
		DragConnection:Disconnect()

		IsButton1Down = false
	end
end)

By direction you span do you mean if you’re turning a given direction the object should be thrown to that direction as well? If so there are 2 ways you can go about this as far as I know.

  1. You can store the previous target position before the current one and subtract new from old to get the direction the object should be thrown at. I attempted this method and it worked roughly, but doesn’t control that nicely.

  2. You can use UserInputService to get the mouse delta, find the angle of the delta. On top of this, find the right vector and up vector of the mouse’s unit ray (you may have to construct it yourself) and then get the impulse direction vector by doing sine(angle) * upvector + cosine(angle) * rightvector.