A way to detect damage and the amount of it

Basically, I was making a sword script and I decided to add a parry feature that reduces the damage dealt to the sword owner and I ran into a problem. Is there a way to detect the amount of damage that was given to the current tool owner?

You could try having a RemoteFunction that whenever is fired by a player stores when they last parried, and whenever you register a hit to a player, detect if they are parrying and if the parry is valid at that very moment.

Basic example of how most people might handle it:

local ParryEvent = ...
local HitEvent = ...

local Parrying = {}

local ParryCooldown = .5
local ParryTime = .5

ParryEvent.OnServerInvoke = function(Player)
    local Parry = Parrying[Player]
    local Clock = os.clock() -- Current time to calculate cooldowns

    if not (Parry and (Parry < (Clock + Cooldown))) then
        Parrying[Player] = Clock
        return true
    end
    return false
end
HitEvent.OnServerEvent:Connect(function(Player, Target)
    local SomeDamageValue = ...
    local Parry = Parrying[Target]

    if Parry and (Parry <= (os.clock() + ParryTime)) then
        SomeDamageValue /= 2 -- Basic reduction
    end
    -- Register hits
    ...
end)

This isn’t what I actually wanted. I used Health.Changed event and now it does work as I wanted.

What you said you wanted was kind of confusing. Also, using Humanoid.HealthChanged may be bad, as if the player takes that damage and is not instantly given health back, then they will die instead of have their damage reduced.