Still have questions? Join our Discord server and get real time help.
1

# Can someone help me use percentages properly in my script?

Edited 21 days ago

I wan't to make it so that the less blood you have, the less damage you deal. If your blood is at 100%, you deal normaI damage. I was thinking of using a percentage to do this.

I was thinking of something like this.

Humanoid:TakeDamage(dmg / %ofblood)


but honestly I don't know how i'd be able to do this. %ofblood would be the current percentage of blood you have, like 20% or 50% of 100%, and dmg would be the damage, humanoid is the player your hitting.

Any and all help is appreciated!

1
RAFA1608 357
21 days ago
Edited 21 days ago
local percentofblood = 100

local damage = 10

local dmg = damage/100 * percentofblood

--Humanoid as in the victim you've hit
Humanoid:TakeDamage(dmg)


Basically what this does, is that it divides it by one hundred, and multiplys it by the percentage of blood. If its 99% of blood, itll become slightly lower. If its 50%, it'll become half. If its 25%, 20% and 10%, it will become 1/4, 1/5, and 1/10 of damage, respectively. Hope this helps!

0
I'll test this right now, if it works, i'll happily accept your answer! :) ErskinePierre 46 — 21d
0
Give me awhile to fully set it up(my damage system is more complex then you might think). If it doesn't work, i'll let you know with an additional comment. ErskinePierre 46 — 21d
0
Accepted, sorry for taking so long. ErskinePierre 46 — 20d