Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How can you create safe, lossless datastores?

Asked by
LostPast 253 Moderation Voter
6 years ago

I am confused how to make Datastores Safely save information. I am wondering how to make sure an error doesn't lose someone all of their Currency even if roblox is erroring really bad.

Should I do;

pcall(function()
    local DSCurrency = DSplrStats:GetAsync("DSCurrency")
    if DSCurrency then
        Stats.UpdateStat(uID,"Currency",DSCurrency)
    end
end)))

or maybe;

coroutine.resume(coroutine.create(pcall(function()
    local DSCurrency = DSplrStats:GetAsync("DSCurrency")
    if DSCurrency then
        Stats.UpdateStat(uID,"Currency",DSCurrency)
    end
end)))

1 answer

Log in to vote
1
Answered by 6 years ago

I think the 1st one is ok. Something I've seen people do (and also in this tutorial: http://robloxdev.com/articles/In-Game-Currency-with-Roblox ,in the currency manager module, bottom of the page, line 21) is they're retrying 3 times if pcall doesn't return success.

So I wouldn't bother that much with the 1st variant, as long as you wrap it in pcall and save the data every few minutes, when the player leaves and on server shutdown, it's gonna be fine.

Ad

Answer this question