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!

6 comments
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
... get any? Thanks!
You can if you upload the place so studio is connected to that place allowing data store access.
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.
Try using pcall or loops. Sometimes Datastore randomly fails.
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