Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

[URGENT] API Services Returned with Error 500 (Internal Server Error)?

So here is my server script in Workspace:

local ds = game:GetService("DataStoreService")
local ss = ds:GetDataStore("StageStore")
local fs = ds:GetDataStore("FinishStore")
local function load(plr)
	for i = 1,3,1 do
		local success, err = pcall(function()
			local stats = Instance.new("Folder",plr)
			stats.Name = "leaderstats"
			local stage = Instance.new("NumberValue",stats)
			stage.Name = "Stage"
			stage.Value = ss:GetAsync(plr.UserId,stage.Value) or 1
			local f = Instance.new("NumberValue",stats)
			f.Name = "Finishes"
			f.Value = fs:GetAsync(plr.UserId,f.Value) or 0
		end)
		if success then 
			break
		elseif err then
			warn(err)
		end
	end
end

local function save(plr)
	for i = 1,3,1 do
		local success, err = pcall(function()
			ss:SetAsync(plr.UserId,plr.leaderstats.Stage.Value)
			fs:SetAsync(plr.UserId,plr.leaderstats.Finishes.Value)
		end)
		if success then 
			break
		elseif err then
			warn(err)
		end
	end
end

game.Players.PlayerAdded:Connect(function(plr)
   load(plr)
end)

game.Players.PlayerRemoving:Connect(function(plr)
    save(plr)
end)
game:BindToClose(function()
    for _, plr in ipairs(game.Players:GetPlayers()) do
        coroutine.wrap(save)(plr)
    end
end)

This is the warning I get:

API Services rejected request with error. HTTP 500 (Internal Server Error)

This only started happening about an hour or two ago. Before then, the script worked. Is there a problem with my script or is it a Roblox error?

2 comments

0

Did you enable API Services?

0

Yes.

1 answer

All it is, is a Roblox error signifying that it failed the request. It will happen every now and then, that's why you should always have a pcall and keep retrying.

2 comments

0

How many times should I retry if it fails?

0

5 times should be fine.

This discussion is preserved as it was. New answers, comments, and votes are closed.