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

Datastore testing is giving errors sometimes?

Asked by 7 years ago

I've been experimenting with the Datastore in ROBLOX recently. After huge amounts of tests over the years, I'm sometimes greeted with ROBLOX unable to process my query due to the servers being down or something.

This is currently what I use;

pcall(function()
    local test = serviceDatastore:GetDataStore('test')

    if test:GetAsync('test') == 'yum' then -- if the value to the key is yum then we know the datastore is working because it's returned 'yum'
        return true
    else
        return false
    end
end)

Is there a more efficient way to do this? Thanks!

0
Hey Vecaxo! There are a number of problems that may arise from code like this. I do know that DataStore returns an error if you attempt to access it from Play mode; this is not a problem with your code, rather, ROBLOX making clear that you cannot use DataStore from Play mode. That said, I cannot be sure that is the problem, given that there is no error to be seen. Mind sending the output, if you g tkcmdr 341 — 7y
0
... get any? Thanks! tkcmdr 341 — 7y
0
You can if you upload the place so studio is connected to that place allowing data store access. User#5423 17 — 7y
0
No there are no errors right now, the script is working great. I'm just wondering if there is a more efficient way in doing it like a ROBLOX function or something. WelpNathan 307 — 7y
View all comments (2 more)
0
Try using pcall or loops. Sometimes Datastore randomly fails. Vezious 310 — 7y
0
They do fail because ROBLOX is down, I just wanted to know if there is a more efficient way of seeing if a datastore was down. No one read my question right so it doesn't matter now haha WelpNathan 307 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
local success, message = pcall(function()
    local test = serviceDatastore:GetDataStore('test')

    if test:GetAsync("test") == "yum" then
        return true
    else
        return false
    end
end)

if success then
     --code here
else
     print("An error occurred: " .. message)
end

You use pcall to check that the block of code will work, else we will do other things or do something else to fix that.

0
i don't think you understood what i meant, doesn't matter. this question is closed. WelpNathan 307 — 7y
Ad

Answer this question