How to detect when a user takes damage and modify that damage?

What i want to achieve is a script that can detect when the client takes damage and modify that damage to reduce it or increase it. (ON THE SERVER)
Why do i want this? I feel like increasing the health by armor isnt like a “cool” way to do it. I want an actual damage reducing armor, not health increasing.
I heard there was a module that would allow you to do this. But i dont know if its true and where to find it.

If someone could help me figure this out i would be thankfull.

What you could do is whenever someone is supposed to get damaged, send it to a script (or use a module script) where it can do the reductions and a whole bunch of math magic. After that, tell the client that is being hit that you have been damaged with x amount.

You would have to do the reduction before dealing damage so that someone doesn’t die even if they have the right amount of health

Here’s how I would do it with a sword (if the hit detection is server sided):

blade.Touched:Connect(function(hit)
    if hitCooldown == false and hit.Parent ~= tool.Parent then
         DamageModule.inflictDamage(weapon, hit.Parent) --This is where the reduction takes place, the module script will also damage the victim (hit.Parent).
    end
end)

If hit detection is client sided:

blade.Touched:Connect(function(hit)
    if hitCooldown == false and hit.Parent ~= tool.Parent then
         RemoteEvent:FireServer(weapon, hit.Parent) --The script receiving this can inflict damage and do reductions.
    end
end)
1 Like