Object throw velocity

Hello. I made a grab system with the ability to throw an object, but light objects are thrown too hard, or, on the contrary, weakly. Video below.

I want to make the throw speed adjustable depending on the weight of the object. The code is below.

local grabEvent = script.Parent.GrabEvent

local up = false
local curObject

local hrp = script.Parent.Parent:WaitForChild("HumanoidRootPart")

function changePos(alignPos:AlignPosition)
	repeat alignPos.Position = script.Parent.GrabPart.Position	
		wait()
	until up
end

grabEvent.OnServerEvent:Connect(function(plr, act, object)
	if act == "GrabStart" then
		up = false
		curObject = object
		local alignPosition = Instance.new("AlignPosition", object)
		alignPosition.Attachment1 = script.Parent.GrabPart.Attachment
		local density = object.CurrentPhysicalProperties.Density/2.5
		alignPosition.Responsiveness = 100*2/density
		alignPosition.ApplyAtCenterOfMass = true
		local att2 = Instance.new("Attachment", curObject)
		att2.Name = "GrabAtt"
		alignPosition.Attachment0 = att2
		
	elseif act == "GrabEnd" then
		up = true
		curObject:FindFirstChild("AlignPosition"):Destroy()		
		curObject:FindFirstChild("GrabAtt"):Destroy()
	elseif act == "Camera" then
		script.Parent.GrabPart.CFrame = object
	elseif act == "Throw" then
		up = true
		local alignPos = curObject:FindFirstChild("AlignPosition")
		alignPos.Attachment0:Destroy()
		alignPos:Destroy()
		local density = curObject.CurrentPhysicalProperties.Density/2.5
		curObject.Velocity = script.Parent.GrabPart.CFrame.LookVector * 50/density
		curObject = nil
	end
end)

The code hasn’t been polished yet, so don’t be surprised.

You’re applying velocity directly, which doesn’t account for mass of the object. If you want the items to be thrown at the same ‘speed’, just set the velocity directly:

local speedOfThrow = 50
curObject.Velocity = script.Parent.GrabPart.CFrame.LookVector * speedOfThrow

By dividing by density, you’re reducing the throw velocity as the part becomes more dense.

If you wish for a system where objects get thrown more-or-less based on their size/weight, use the part’s mass as that will take into account both density and volume (Mass = Density * Volume).

local impulse = script.Parent.GrabPart.CFrame.LookVector * (throwPower / curObject:GetMass())
curObject:ApplyImpulse(impulse)

Edit: ApplyImpulse might already consider the part’s mass (I can’t remember). If you’re getting incorrect results, simply replace the line with local impulse = script.Parent.GrabPart.CFrame.LookVector * throwPower

the impulse method helped (it automatically consider the mass)

Can you help with the AlignPosition part? I need to adjust Responsiveness depending on the mass.

If it’s just responsiveness, then replacing density with part:GetMass() should solve most of your issues. You may need to re-adjust your scaling factor (100*2) to account for the different values.

Also could be worth math.clamp()ing the value to ensure you don’t get ridiculously high or low responsiveness values if the part is massive or tiny.