I need a formula to make drain according to a value

Well, I will describe the problem:
I have a energy value and mastery value.
I want the energy of the player with the minimum mastery to be multiplied by x0.95 of the value every second.
And when you have the maximum mastery, I don’t want you to lose anything, that is, the energy would be multiplied by x1.
I want this to be a gradual change, which will be according to the player’s mastery.

Information that may be useful:

The mastery value is applied to transformations, the better the player controls the form, the more mastery he will have.
The max mastery is 100 (100%), and the minimum mastery is 0.01 (0.01%)

I already spent too much time of my life thinking about this… Can anyone help me?

If you keep multiplying any number by 0.95 it will never reach zero. Are you sure that’s what you want? Or do you want 0.05 x the max energy to be removed per second?

1 Like

“Or do you want 0.05 x the max energy to be removed per second?” Exaclty, but already solved!
My friend did this formula:

_G.calculate_drain = function(energy, mastery)
	local Energia = ((energy* 0.4)/mastery)*1.1
	if mastery < 100 then
		Energia = 0

	return Energia

That’s good but I beg you not to use _G

1 Like