Custom explosion damage not working

Hey guys I just recently opened studio back up to try and look at and tweak and old project I had, The only problem is that suddenly the custom explosion bomb I made no longer works (they are pretty much the center of the game). I have tried tweaking it a little but the only conclusion I have come to is that the variable “distance” is returning a negative value for some reason and I can’t seem to figure out why they don’t work anymore. CODE BELOW

wait(5)

local function customExplosion(position, radius, maxDamage)
	local explosion = Instance.new("Explosion")
	explosion.BlastPressure = 750000
	explosion.DestroyJointRadiusPercent = 0
	explosion.BlastRadius = radius
	explosion.Position = position
	script.Parent.explosion.Playing = true
	script.Parent.BoomPart:Destroy()

	local modelsHit = {}


	explosion.Hit:Connect(function(part, distance)
		local parentModel = part.Parent
		if parentModel then 
			if modelsHit[parentModel] then
				return
			end
			modelsHit[parentModel] = true

			local humanoid = parentModel:FindFirstChild("Humanoid")
			if humanoid then
				local distanceFactor = distance / radius + 5
				distanceFactor = 1 - distanceFactor
				humanoid:TakeDamage(maxDamage * distanceFactor)
				print(maxDamage * distanceFactor)
				print(distanceFactor)
				print(distance)
				print(radius)
			elseif part.Name ~= "Ground" and part.Name ~= "GameSpawn" then
				part:BreakJoints()
				part.Anchored = false
			end	
		end
	end)

	explosion.Parent = game.Workspace
	script.Parent:GetChildren().Transparency = 1
	script.Parent:GetChildren().CanCollide = false
end

customExplosion(script.Parent.BoomPart.Position, 20, 75)
wait(1)
script.Parent:Destroy()

I managed to fix it, not sure why I was adding 5 to the result of the distance / radius but it was causing a less that wanted result