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)
Think about it. The damage variable in your script is the difference between the current health and the humanoid's maximum health.
If the humanoid's health decreased from 64 to 13, the difference would be 87 points (not 51, since you're subtracting it from the humanoid's maximum health), which scales to 52.2.
You should instead find the difference between the humanoid's current health and the humanoid's health from before it took damage. So the scaled damage from 64 to 13 would be 30.6 (51 × 0.6).