This script is from an example on the roblox wiki, and I'm wondering how the function finds arguments for the parameters hitPart and partDistance?
local maxDamage = 100 -- maximum possible damage. could also be based off of the Humanoid's MaxHealth
local explosion = Instance.new("Explosion")
explosion.DestroyJointRadiusPercent = 0 -- neck welds won't be destroyed
explosion.BlastRadius = 8
explosion.Hit:connect(function(hitPart, partDistance)
local humanoid = hitPart.Parent and hitPart.Parent:FindFirstChild("Humanoid")
if humanoid then
local distance_factor = partDistance / explosion.BlastRadius -- get the distance as a value between 0 and 1
distance_factor = 1 - distance_factor -- flip the amount, so that lower == closer == more damage
humanoid:TakeDamage(maxDamage*distance_factor) -- 0: no damage; 1: max damage
end
end)
explosion.Parent = workspace
