Im trying to make different NPC which has their own abilities.
Today, I came up an idea, when an NPC takes damage, it deals less.
For example, I have a gun which deals 10 damage
But the dummy takes 70% of the damage only, which is 7
Can anyone suggest how I can do this?
something like this?
local hitDamage = 10 -- gun damage
local lessDamagePercentage = 30
-- takes the 30% less damage
local damage = hitDamage - (hitDamage * (lessDamagePercentage / 100))
Humanoid:TakeDamage(damage)
But how can I make the script inside the NPC instead of the gun
You could call a function that does damage to the NPC each time, applying the less damage. However, you could just increase the maxhp of the npc instead of using percentages of damage.
It is rather tricky to get it working without directly applying less damage. In theory you can record the last health and calculate the difference and then add back a proportional amount.
How can I calculate the difference?