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!
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.