Http 500 when I'm trying to get data out of a datastore

It suddenly broke when I was ingame and I’m not really sure why

line 38 is

	local data = DataStore:GetSortedAsync(false, maxItems, minValueDisplay, maxValueDisplay)

line 90 is just the function

getItems()

if you need the full script tell me

Roblox is currently down for me aswell

not publishing , saving ect

3 Likes

That’s probably why, really annoying as I was in the middle of testing it and then that happened.


yeah

2 Likes

Always pcall your API requests to handle issues related to Roblox services being down. A good solution would be to recursively ask for the data if it fails.

function GetData(attempts, max)
	attempts = attempts or 0
	local data 
	local Success, Error = pcall(function()
		data = DataStore:GetSortedAsync(false, maxItems, minValueDisplay, maxValueDisplay)
	end)
	if Success then 
		return data 
	else 
		warn(Error, "attempt = "..attempts)
		task.wait(attempts)
		if attempts <= max then 
			return GetData(attempts+1)
		else 
			warn("max attempts reached!") 
			return nil 
		end 
	end
end

local data = GetData(nil, 5)

if not data then 
	--datastores may be down
	--handle it depending on how your game works
end
1 Like