Is it possible to exceed the maximum number of an IntValue?

Hey there!

I’m using a currency in my game, and this number is converted to a TimeValue like days / months …

I’m in front of a problem, The intvalue reaches its maximum value so the player’s currency stucks to 3.15 months at the maximum.

It’s why I would like to know if there is a way to exceed this number?

You could try having multiple IntValues, one for months, one for days, seconds, etc. This will increase its storage capacity by a lot. Actually, I am not sure myself if you can actually exceed the maximum value of an IntValue

You won’t be able to use an IntValue, but you could use this BigInteger library.

My game currencies is time and it comes from “Picoseconds” to “Milleniums”.

My script converts the number of picoseconds to a time value.

Like if you have 1000 picoseconds it will be written “1 nanosecond”.

But when you buy something it will removes you 1000 picoseconds.

So i don’t really know how can I do this and it will be very hard for me to remove the time when players by stuff.

There is still a way to make the purchase through a conversion/remove algorithm, but I understand.
I found another discussion talking about this:

I think this reply should solve the problem

It looks great but I don’t have any idea on How to use this module.

I red the post you sent me but …

To be honest, I don’t really understand what should I do to replace my previous intValue to implement this module.

So, could you explain to me how should I implement this module to my game?

you could try using strings and using string manupulation if you don’t want to use the better other solutions that have already been posted.
Adding "700000000" and 500 would be something like this:

local OldValue = "700000000"
local AddValue = 500
AddValue = tostring(AddValue)
local ToAddTogether = string.sub(OldValue, -1 - #AddValue) -- # is length, taking another character in case the other number is too large
-- Example: 99 + 2 is 101, which is 3 characters long when added, so we need that extra character
ToAddTogether += AddValue
ToAddTogether = tostring(ToAddTogether)
local AddedValue = string.sub(OldValue, 0, #OldValue - #ToAddTogether) .. ToAddTogether
print(AddedValue) -- 700000500

Strings aren’t numbers so don’t suffer from floating point issues, and smaller ints don’t suffer from the errors either.
Note going back to number can make it have floating point issues, so I would only take from the value and convert to number, never taking the number and converting it to a string and write that back to the saved value, as that could add/remove 100s of thousands of your units from the real value.

What if you just made the actual value used in the scripts be whatever’s in the IntValue (make it a NumValue instead for decimals) times a large number, like 1000 or something.

This would mean that when you have 0.001 in the IntValue, when you use the IntValue in a script it multiplies that value by 1000 to equal 1. You’d do this whenever you need to make an calculations in a script/localscript.

I know it’s a strange workaround, but just an idea.