How to format decimal points to intvalues

How can I format an IntValue to make 100 look like 1.00 and 458 look like 4.58 as an example, I wanna make a Wild-West kind of game with currencies going to decimals and by using IntValues to keep track and make stores easier

1 Like

Hi there!

I believe this YouTube video would be of assistance to you.

No like I mean how do I format it to add a decimal point in between the 3rd and the 2nd number for example 9827934 becomes 98279.34

You can just divide the value by 100

local money = IntValue.Value / 100
2 Likes

Clearly you must first divide your number by 100 then consider:

local number = 100
local formattedString = string.format( "%.2f ", number) 

Now the number will be presented with two decimal places. So it’ll out 100.00.

However this will return a string so if you want a number do:

local formattedNumber = tonumber(formattedString)

If you want to understand why you have to format it with "%.2f " see formatting.

1 Like

Alright will use that! Thanks <3

Of course, if the end goal is to have it as a number, ditch the formatting and just divide by 100 because numbers have no formatting.