I have a few systems in my game that increases/decrease numbers by a percent, however, when testing things I realized if the values are ever 1 it will never increase another thing I realized is I don’t think I’m calculating things right.
For demonstration, I have an ability that heals 3% of the player’s hp everytime they land a hit
local function Heal(humanoid,percent)
humanoid.Health = Util:IncreaseNumByPercent(humanoid.Health,percent)
end
-- gets called when a hit is made
Class.Passive = function(humanoid)
Heal(humanoid,3)
end
Here is the IncreaseNumByPercent
function
local function decimalRound(num, places)
local power = 10^places
return math.round(num * power) / power
end
function Utils:IncreaseNumByPercent(number : number, percent : number)
local result = number * (1 + (percent/100))--decimalRound(number * (1 + (percent/100)),0)
return result
end
If the players health is 1 and they tried to heal it would stay at 1 which makes sense because math and also I know its only 3% but it only ends up at 1.03 I feel like that’s to low to be correct?