Is there a better way to check how hard a part hit another part?

Tnt something
if it gets hit hard enough like from gmod it explodes
i tried making something myself, and it worked somewhat, but is not too great and if put on any sort of conveyor or “cannon” it explodes immediately

-- Segment of the code

function Hit(Velocity)
	local Resistance = SelfMass/5 * Explosive
	
	local X = if Velocity.X > MinVelocity then Velocity.X else 0
	local Y = if Velocity.Y > MinVelocity then Velocity.Y else 0
	local Z = if Velocity.Z > MinVelocity then Velocity.Z else 0	
	
	local Damage = (X+Y+Z) * SelfMass
	if Damage > Resistance then
		TakeDamage((Damage -  Resistance)/10)
	end
end

function GotHit(Velocity, Mass)
	local Resistance = SelfMass/5 * Explosive
	
	local X = if Velocity.X > MinVelocity then Velocity.X else 0
	local Y = if Velocity.Y > MinVelocity then Velocity.Y else 0
	local Z = if Velocity.Z > MinVelocity then Velocity.Z else 0
	
	local Damage = (X+Y+Z) * Mass
	
	if Damage > Resistance then
		TakeDamage((Damage - Resistance)/10)
	end
end


script.Parent.Touched:Connect(function(TouchedPart)
	if HasExploded then return end
	local Velocity = script.Parent.AssemblyLinearVelocity
	local Velocity2 = if TouchedPart:IsA("Part") then TouchedPart.AssemblyLinearVelocity else Velocity
	
	print(Velocity)
	if Velocity.X > MinVelocity or Velocity.Y > MinVelocity or Velocity.Z > MinVelocity then 
		Hit(Velocity)
	end
	
	if Velocity2.X > MinVelocity or Velocity2.Y > MinVelocity or Velocity.Z > MinVelocity then
		if not TouchedPart.Anchored then GotHit(Velocity2, TouchedPart.Mass) end
	end
end)
Full Code
local HasExploded = false
local MinVelocity = 10
local Explosive = 300

local SelfMass = script.Parent.Mass
local TntHumanoid = script.Parent.TntHumanoid
local Fire = script.Parent.TntFire
local Smoke = script.Parent.Smoke


function Explode()
	HasExploded = true
	local Explosion = Instance.new("Explosion")
	Explosion.Parent = workspace
	Explosion.Position = script.Parent.Position
	script.Parent:Destroy()
end

function TakeDamage(Num)
	print("Took Damage: " .. Num)
	TntHumanoid:TakeDamage(Num)
end

function Damaged()
	if HasExploded then return end
	local Health = TntHumanoid.Health
	if Health == TntHumanoid.MaxHealth then
		Fire.Enabled = false
		Smoke.Enabled = false
	elseif Health > TntHumanoid.MaxHealth * 2 / 3 then
		Fire.Enabled = true
		Fire.Heat = 4
		Fire.Size = 7
		Smoke.Enabled = false
	elseif Health > TntHumanoid.MaxHealth * 1 / 3 then
		Fire.Heat = 5
		Fire.Size = 8
		Smoke.Enabled = false
	elseif Health > 0 then
		if not Fire.Enabled then
			Fire.Enabled = true
			Fire.Heat = 5
			Fire.Size = 8
		end
		
		
		Smoke.Enabled = true
		Smoke.Opacity = 0.1
		Smoke.RiseVelocity = 0
		Smoke.Size = 0.1
		Smoke.TimeScale = 1
	elseif Health <= 0 then
		Explode()
	end
	
end

function Hit(Velocity)
	local Resistance = SelfMass/5 * Explosive
	
	local X = if Velocity.X > MinVelocity then Velocity.X else 0
	local Y = if Velocity.Y > MinVelocity then Velocity.Y else 0
	local Z = if Velocity.Z > MinVelocity then Velocity.Z else 0	
	
	local Damage = (X+Y+Z) * SelfMass
	if Damage > Resistance then
		TakeDamage((Damage -  Resistance)/10)
	end
end

function GotHit(Velocity, Mass)
	local Resistance = SelfMass/5 * Explosive
	
	local X = if Velocity.X > MinVelocity then Velocity.X else 0
	local Y = if Velocity.Y > MinVelocity then Velocity.Y else 0
	local Z = if Velocity.Z > MinVelocity then Velocity.Z else 0
	
	local Damage = (X+Y+Z) * Mass
	
	if Damage > Resistance then
		TakeDamage((Damage - Resistance)/10)
	end
end


script.Parent.Touched:Connect(function(TouchedPart)
	if HasExploded then return end
	local Velocity = script.Parent.AssemblyLinearVelocity
	local Velocity2 = if TouchedPart:IsA("Part") then TouchedPart.AssemblyLinearVelocity else Velocity
	
	print(Velocity)
	if Velocity.X > MinVelocity or Velocity.Y > MinVelocity or Velocity.Z > MinVelocity then 
		Hit(Velocity)
	end
	
	if Velocity2.X > MinVelocity or Velocity2.Y > MinVelocity or Velocity.Z > MinVelocity then
		if not TouchedPart.Anchored then GotHit(Velocity2, TouchedPart.Mass) end
	end
end)

TntHumanoid:GetPropertyChangedSignal("Health"):Connect(Damaged)

you’ll probably want to have some system that determines how “directly” something was hit (for example, a fast moving object may not explode if it merely glances off of something)

for this i would recommend looking into dot products of vectors
i put together a quick example of this if you want to take a look
explode.rbxl (31.0 KB)
the important part is this

-- raycast to find surface normal
-- (surface normal is direction vector of surface)
local res = workspace:Raycast(part.Position, (tp.Position-part.Position)*10, raycastParams)
	
if res then
	-- see how "close" the firing angle is to the angle of the surface, higher is closer
	local strength = math.abs(dir:Dot(res.Normal)) -- as long as dir is a Unit vector, strength will be between 0 and 1 (1 being directly at surface, 0 being parallel)

	-- above threshold, explode
	if strength > 0.6 then -- pick any number that suits
		-- direct hit!
	end
end