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

How to handle datastores failing from roblox?

Asked by
trecept 367 Moderation Voter
5 years ago

My datastore system works fine, I have it so when I'm unable to get the datastore (if it's failing or down) it kicks the player, however recently datstores failed and I was kicked but my data was still overwritten. Should I be kicking players or not? What is the best way to handle errors from roblox?

1 answer

Log in to vote
1
Answered by 5 years ago

Wrap all datastore requests in pcall like so:

local success, message = pcall(function()
    Datastore:SetAsync(key, data)
end)

if not success then
    -- If the datastore failed, you should retry saving this player's data.
    warn("Datastore failed, retry saving the players data.")
else
    -- Everything worked!
    print("Datastore worked, saves stats accordingly.")
end
0
I would also really recommend this article on saving data: http://robloxdev.com/articles/Saving-Player-Data DemotedGnar 95 — 5y
Ad

Answer this question