DarkRP Take money from victim and give to attacker

How do i do so when attacker kills victim the attacker gets x amount of money from victim, as long as victim has the x amount of money already
so like victim has 1000$ and the attacker gets 10$ for killing then the victims money would be 990$
And if victim has 0$ then do nothing

And i know about the drop money on death in DarkRP but I do not want this

I Found this

hook.Add( "PlayerDeath", "A_Unique_Name", function( victim, inflictor, attacker )
    if victim ~= attacker and victim:IsPlayer() and attacker:IsPlayer() then
        attacker:addMoney(50) -- The attacker receives 50 dollars.
    end
end )

But that don’t check if victim has the money

Let me improve my code and give you what you are looking for:

hook.Add( "PlayerDeath", "A_Unique_Name", function( victim, inflictor, attacker )
    if victim ~= attacker and victim:IsPlayer() and victim:canAfford( 50 ) and attacker:IsPlayer() then
        victim:addMoney( -50 ) -- The victim loses 50 dollars (if they can afford it).
        attacker:addMoney( 50 ) -- The attacker receives 50 dollars.
    end
end )
hook.Add( "PlayerDeath", "A_Unique_Name", function( victim, inflictor, attacker )
    if victim ~= attacker and victim:IsPlayer() and attacker:IsPlayer() and victim:canAfford( 50 ) then
        attacker:addMoney(50)
    end
end )

Should be that straightforward. I dont think addMoney checks if they can afford it by default