What I have tried to do is create an armor system that properly absorbs and scales down damage taken instead of just increasing the player's MaxHealth. I have been able to do this but I ran across a problem where the script stops scaling properly and the player takes more damage as their health lowers, I think I didn't go the right way about doing this and I'm stumped.
Code (This is in a script inside of the player and it also accesses a armor durability value inside of the player and I'm sorry if it's spaghetti code I haven't scripted in a while):
function absorbDamage()
if script.Parent.Durability.Value <= 0 then return end
local newHealth = script.Parent.Humanoid.Health
if newHealth < oldHealth ~= true then return end
if newHealth < oldHealth then
if debounce == false then
debounce = true
local damage = script.Parent.Humanoid.MaxHealth - script.Parent.Humanoid.Health
script.Parent.Humanoid.Health = script.Parent.Humanoid.MaxHealth
wait(0.1)
local scaleDamage = damage*0.60
print(scaleDamage)
script.Parent.Humanoid:TakeDamage(scaleDamage)
script.Parent.Durability.Value = script.Parent.Durability.Value - 5
wait(1.5)
debounce = false
end
end
end
script.Parent.Humanoid:GetPropertyChangedSignal("Health"):Connect(absorbDamage)

5 comments
I rewrote the script to find the damage by subtracting the old health from the new health instead of the maximum health, and redefined the old health at the end of the script to be the player's health after the damage was absorbed. This fixed the issue of the scaled damage increasing over time but now the player just won't be damaged at all, or will be healed instead of damaged
Did you keep line 12 as-is? Where you're setting the player's health to MaxHealth?
Yes
It should be oldHealth, not MaxHealth. If my answer worked, do accept it. As this is beyond the scope of the asked question.
I apologize, I still barely use this site, but thank you for the help and I will accept