DataStore Error: "double is not allowed in data stores"

How in the world is this considered a long decimal? (statsValue = 23472475, Number4 = 6520.1 as printed)

local Number1 = statsValue.Value / 3600
local Number2 = Number1 * 10
local Number3 = math.round(Number2)
local Number4 = Number3 / 10
print(Number4)
				
return tonumber(Number4)

1 Like

Round it. The error explicitly says you cannot use ANY decimals

2 Likes

I am guessing you are using OrderedDataStores here, and in the documentation it says you are only allowed positive integers. So make sure you round your numbers before adding them into the store and keep them all positive.

The double value is just the normal lua number so that’s why its saying you are trying to store one (you have decimals in your print and the store can’t convert that number to an unsigned integer).

1 Like

It’s actually because whole numbers are consistent and have predictable behavior when you compare, sort, or even do arithmetic actions with them. On the other side, this is complicated with doubles/floating-point numbers due to precision issues and many more.

Just a friendly FYI :smiley:

2 Likes

Is there a solution then or no?

1 Like

What I would do is tostring() the value, and then tonumber() it when you want to fetch it from the datastore

1 Like

multiply by 100 to save, divide by 100 to get, do the opposite if it doesn’t work

1 Like

As stated by Local_LettuceGiver I would save it as tostring() and then when you want to load the data use tonumber()

1 Like