Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is the Hit event of an explosion returning distances greater than its blast radius?

So I have a tank that fires grenades, and I have the grenade damage based on the distance the explosion center is from a humanoid, but for some odd reason, the distance parameter of the Hit event returns distances that are greater than the blast radius of the explosion itself. I even got values that were twice as large as the blast radius of the explosion itself. Is there any reason for this? Please help.

Here's the main grenade code:

Grenade.Touched:connect(function(Obj)
	if (not Obj:IsDescendantOf(Char)) and (not grenadeHit) then
		grenadeHit = true
		
		expSound:Play()
		
		local Explosion = Instance.new("Explosion")
		Explosion.BlastPressure = grenadeExplosionPressure --This is 50000
		Explosion.BlastRadius = grenadeExplosionRadius --This is 15
		Explosion.DestroyJointRadiusPercent = (grenadeRangeBasedDamage and 0 or 1) --This is currently set to 0
		Explosion.ExplosionType = Enum.ExplosionType.NoCraters
		Explosion.Position = Grenade.Position
		Explosion.Hit:connect(function(Obj, Dist)
			local hitHumanoid = (
				Obj.Parent:IsA("Accoutrement") and findFirstClass(Obj.Parent.Parent, "Humanoid")
				or findFirstClass(Obj.Parent, "Humanoid")
			)
			if hitHumanoid then
				createCreatorTag(hitHumanoid)
				if grenadeRangeBasedDamage then
					local distFactor = 1 - (Dist / grenadeExplosionRadius)
					local baseDamage = distFactor * grenadeDamage
					if Obj:FindFirstChild("damageMultiplier") then
						print(distFactor) --This prints negative numbers for some reason
						hitHumanoid:TakeDamage(baseDamage * Obj.damageMultiplier.Value)
					else
						if Obj.Name == "Torso" then
							hitHumanoid:TakeDamage(baseDamage)
						end
					end
				end
			end
		end)
		Explosion.Parent = workspace
		wait()
		Grenade:Destroy()
	end
end)

Thanks!

1 answer

Explosion.BlastRadius = grenadeExplosionRadius  --This is 15
1 - (Dist / grenadeExplosionRadius)

Math if Dist was > 15 then negative number

3 comments

0

I know that but what I'm asking is why is the event returning distance values that are greater than the radius of the explosion itself? That's what doesn't make sense

0

I'm thinking of 2 things. If the grenade touches more than 1 object would one explosion affect the other and the fact that the grenade can be pushed by blast pressure with it's full force since the grenade isn't anchored(I think)

0

Which would cause another explosion most likely?

This discussion is preserved as it was. New answers, comments, and votes are closed.