How would i add armor thing to soak up extra damage?

While i could just have the player gain extra health while equipping a armor set, is there another way to like check whenever the player takes damage to take some from the armor?

1 Like

Yep, just add the armors extra value to the MaxHealth

Sure, if you know how much health the armor adds then:

local char = script.Parent
local human = char.Humanoid

human:GetPropertyChangeSignal("Health"):Connect(function()
    if human.Health == 100 then return print("No armor") end
    if human.Health > 100 then print("Here subtract the armor health value by (human.MaxHealth - human.Health)
end)
local Armor = 10
local HP = 100
local DMG = 25
HP -= DMG-Armor

--if you want to reduce armour over time
Armor -= DMG/10

This is not what they meant. They asked if there was another way to do this.

You can check a bool value if the player is wearing armor and if it’s true then do less damage. If a projectile or weapon hits the player look for the bool value, if it’s true then instead of doing 50 do 50/2 damage or something.

There are a lot of formulas to reduce damage.

For example, you can use armor as a flat damage reduction (10 damage -10 armor = 0 damage). Terraria uses this system I guess, but damage is always 1 or higher.

You can also make a % reduction based on armor. On League of Legends, damage reduction = armor / (armor+100). The mitigated damage becomes damage*(1-damage reduction). So if you have 30 armor, you get (30/130) = about 23% damage reduction, so 100 damage will become 77 damage. This specific formula makes stacking armor less efficient after some time. For example, 300 armor will mitigate 75% damage, while 400 will mitigate 80%.

Note that 100 is the point where your damage will be halved. You can change 100 to another value as to set at what amount of armor you will get 50% damage reduction.

I wasnt exactly going for something that reduces damage, more of like a second healthbar, kinda like fortnites shield system where all damage gets directed to the shield until theres none left

In this case you can make a new Value for the shield or increase max hp. Setting shield as a separate value enables players to generate them even when they are not Full health. You will have to hide the humanoid default hp bar and use a billboard gui to show the hp and shield value. You can overlap the health bar with the shield bar or make it show up aligned with the hp. You might know how to do this already but to update a resource bar you can get the percentage (current resourceĂ·maxresource) and set the bar x scale size or y scale size as this percentage. The resources would be the player health and max health, and maxresources would be shield and maxshield. You can use tweenservice to create animation effects for the health bar.