Help with life math

how can i make every 3 digits in a value increase 100 life of a player?

my game has very high power values and is leaving players with infinite life, I will try this metadata to see it better, if you have other ideas on how I can make a life system with automatic numbers, show me.

You can do some fancy logarthritis stuff, but the easiest way is probably to just convert it into a string.

math.floor(#tostring(value)/3)*100+100

it seems that “#tostring (value)” only accepts up to 14 digits, then it starts to return 5

Because it’s showing in scientific notation when the value has something like 15 digits or higher for tostring.

Here’s the logarithm approach

math.log(value, 1000) * 100
1 Like

sorry, but i didn’t understand what you meant, can you give me some way to make the player’s life functional?

That’s actually all you need. I forgot about scientific notation, but Blockzez’s code will work.
life = math.log(value, 1000) * 100

In case you meant every 3 values higher, here’s a solution:

local value = -- Your value
local health = -- Humanoid's health

health = health + math.floor(value*100/3)

And even if it wasn’t I still wanted to do it for fun haha.

Have a great week everyone!

1 Like

Oh, and by the way,

Wouldn’t it be this instead?

health = health + math.floor(#tostring(value)/3)*100

Why are you adding 100 at the end? Perhaps I just missed something though.

The way I did it would do this.
1 - 100
100 - 200
100000 - 300
100000000 - 400

The +100 prevents this.
1 - 0
100 - 100
100000 - 200

The way you did it in your second post would do this because it is adding to a current value, leading to exponentiation.
1 - 0
100 - 100
100000 - 300
100000000 - 600

The way you did it in your first post works like this
1 - 33
2 - 99
3 - 199
4 - 332
There are a few reasons. First is, you are getting the value itself and not the number of digits in the value. Second, you are multiplying by 100 inside of math.floor. And last, you are adding to the current value rather than setting the value. As with your latter code, this leads to exponentiation. He wants every three digits to increase the value by 100, not increase by 100*digits/3.

1 Like

Is that what OP wants? He says, “ how can i make every 3 digits in a value increase 100 life of a player?” Wouldn’t this mean that he wouldn’t want 1 digit to give 100 at the start?

Yes that’s why I was wondering why he included that.

Shouldn’t this be what OP wants?

Well, I suppose the only way to know is if OP himself responds.

Good stuff!