Hello,
In my game, i need to store really large numbers. The issue i am having is that i am unable to store them in a DataStore as numbers(since it is in a table and seems to be too big for it apparently). I tried to turn it into a string but that didn't work either. I am stuck and am not too sure how to go about this.
Saving
local function autoSave()
while wait(SAVE_INTERVAL) do
local tries = 0
local success
repeat
tries = tries + 1
success = pcall(function()
DDS:SetAsync(SAVE_KEY, Data)
end)
if not success then wait(1) end
until tries == 3 or success
if not success then
warn("Cannot save data for player!")
end
end
end
Loading
localSave = save
local SAVE_KEY = player.userId.."-"..localSave
local Cashmoney = game.ServerStorage.MoneyStorage:WaitForChild(player.Name) -- Get's the players Money Storage
local Success, Error
repeat
Success, Error = pcall(function()
Data = DDS: GetAsync(SAVE_KEY)
end)
if not Success then
print("an error has occured when loading "..player.Name.."'s cash"..Error)
wait(1)
end
until Success or not player or not player.Parent
if player and player.Parent then
if not Data then
Data = {CASH_DEFAULT, KRYSTALIN_DEFAULT, CHAPTERS_DEFAULT, TT_DEFAULT}
DDS:SetAsync(SAVE_KEY, Data)
print("Data Initated for "..player.Name..". Wecome "..player.Name.."!")
end
-- Do things with the data
spawn(autoSave)
end
local SERVER_CASH = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
local SERVER_KRYSTALIN = game.ServerStorage.KrystalinStorage:FindFirstChild(player.Name)
SERVER_CASH.Value = tonumber(Data[CEnum.DATA_TYPE.CASH])
SERVER_KRYSTALIN.Value = tonumber(Data[CEnum.DATA_TYPE.KRYSTALIN])
SERVER_CASH.Changed:Connect(function()
Data[CEnum.DATA_TYPE.CASH] = SERVER_CASH.Value
print(Data[CEnum.DATA_TYPE.CASH])
end)
SERVER_KRYSTALIN.Changed:Connect(function()
Data[CEnum.DATA_TYPE.KRYSTALIN] = SERVER_KRYSTALIN.Value
end)
Please help, i would love to get this to work. By the way, SERVER_CASH and SERVER_KRYSTALIN are number values. Thank you!
