Roblox gun damage: range falloff, headshots and armour in Luau
Short answer
Compute damage on the server from the weapon's base damage, a falloff multiplier for the hit distance (interpolate between range points such as 0-50 studs = 1.0, 150 studs = 0.6), a hit-zone multiplier (head 1.5-2.0, limbs 0.8-0.9) and armour that absorbs part of it. Keep it as plain functions so you can test the numbers.
Copy-paste code
ReplicatedStorage/DamageMath (ModuleScript)
local DamageMath = {}
-- points: { {range, mult}, ... } sorted by range, e.g. { {50, 1}, {150, 0.6}, {300, 0.4} }
function DamageMath.falloff(points, distance)
if distance <= points[1][1] then return points[1][2] end
for i = 2, #points do
local a, b = points[i - 1], points[i]
if distance <= b[1] then
local t = (distance - a[1]) / (b[1] - a[1])
return a[2] + (b[2] - a[2]) * t
end
end
return points[#points][2]
end
local ZONES = { Head = 1.6, UpperTorso = 1, LowerTorso = 1, Torso = 1, HumanoidRootPart = 1 }
function DamageMath.compute(weapon, distance, partName)
local zone = ZONES[partName] or 0.85 -- limbs and accessories
return math.floor(weapon.damage * DamageMath.falloff(weapon.falloff, distance) * zone * 10 + 0.5) / 10
end
-- armour absorbs `soak` of the damage until it runs out
function DamageMath.applyArmour(amount, armour, soak)
local absorbed = math.min(armour, amount * soak)
return amount - absorbed, armour - absorbed
end
return DamageMathGood to know
Round to one decimal on both client and server so hit numbers shown to the player match the real damage.
Balance with time-to-kill, not damage alone: the free weapon stats balancer shows shots and seconds to kill for every gun side by side.
Salvowick FPS Combat Framework: A shooter where the server has the final word
from $12Salvowick's Damage module (in the free sampler) is the tested version of this maths, and the full framework wires it into server-checked shots, reloads, recoil and a killfeed.
Secure checkout · 14-day fix-or-refund if it doesn't work as described (terms)Questions
What headshot multiplier is normal?
Most shooters use 1.5 to 2.0 for rifles; snipers often one-shot to the head. Check time-to-kill in the balancer.
Should limbs take less damage?
Many games use 0.8 to 0.9 so body shots stay the main target.
Free: the Roblox Starter Kit
7 free Luau modules (damage, pets, shop formatting, admin audit log, tycoon guards and more) plus 3 free calculators, then 5 short emails with the scripting fixes we see go wrong most often.