Error while loading / saving data: API Services rejected with error. HTTP 0 (HTTP 403)

Hello, Developers.

I am making a DataStore system for a project and this pops up when I test:

API Services and HTTP Services are both enabled. Is this a bug with ROBLOX, or did I make a mistake in my code?

DataStore Module
local module = {}

--// DATASTORE

local DataStore = game:GetService("DataStoreService")

--// GET DATASTORES

local Player_Data = DataStore:GetDataStore("PlayerData", 1)
local ToolsOwned = DataStore:GetDataStore("ToolsOwned", 1)
local BackpacksOwned = DataStore:GetDataStore("BackpacksOwned", 1)

--// LOAD DATA FUNCTION

function module.LoadData(plr)
	
	--// VARIABLES
	local Key = plr.UserId -- Key for DataStore
	local Stats = plr:WaitForChild("leaderstats") -- Player stats
	local Coins = Stats:WaitForChild("Coins") -- Coins
	local rPlayer = game:GetService("ReplicatedStorage").Players:WaitForChild(plr.Name) -- ReplicatedStorage Player
	
	local Success, Err = pcall(function() -- Pcall incase an error occurs
		
		--// REGULAR DATA
		
		local PlayerData = Player_Data:GetAsync(Key) -- Gets Data
		
		if PlayerData then -- If player data exists, then load it
			
			Coins.Value = PlayerData.Coins
			rPlayer.ToolEquipped.Value = PlayerData.ToolEquipped
			rPlayer.BackpackEquipped.Value = PlayerData.BackpackEquipped
			
		else -- If it doesn't, set to default
			
			Coins.Value = 0
			rPlayer.ToolEquipped.Value = "Starter Tool"
			rPlayer.BackpackEquipped.Value = "Starter Backpack"
			
			local ValuesToSave = {
				Coins = Coins.Value,
				ToolEquipped = rPlayer.ToolEquipped.Value,
				BackpackEquipped = rPlayer.BackpackEquipped.Value
			}
			
			Player_Data:SetAsync(Key, ValuesToSave) -- Saves Data
			
		end
		
		--// TOOLS OWNED
		
		local ToolsOwnedData = ToolsOwned:GetAsync(Key) -- Gets data
		
		if ToolsOwnedData then -- If data exists then load it
			
			for _,v in pairs(ToolsOwnedData) do -- Iterates through the data
				
				local Tool = game:GetService("ReplicatedStorage").Tools:FindFirstChild(v)
				
				if Tool then
					
					local Temp = Instance.new("BoolValue")
					Temp.Name = v
					Temp.Parent = rPlayer.ToolsOwned
					
				end
				
			end
			
		else -- If data does not exist, set to default
			
			local Temp = Instance.new("BoolValue")
			Temp.Name = "Starter Tool"
			Temp.Parent = rPlayer.ToolsOwned
			
		end
		
		--// BACKPACKS OWNED
		
		local BackpacksOwnedData = BackpacksOwned:GetAsync(Key) -- Gets data
		
		if BackpacksOwnedData then -- If data exists then load it
			
			for _,v in pairs(BackpacksOwnedData) do -- Iterates through the data
				
				local Backpack = game:GetService("ReplicatedStorage").Backpacks:FindFirstChild(v)
				
				if Backpack then
					
					local Temp = Instance.new("BoolValue")
					Temp.Name = v
					Temp.Parent = rPlayer.BackpacksOwned
					
				end
				
			end
			
		else -- If data does not exist, set to default
			
			local Temp = Instance.new("BoolValue")
			Temp.Name = "Starter Backpack"
			Temp.Parent = rPlayer.BackpacksOwned
			
		end
		
	end)
	
	if not Success then -- Checks if it errored
		warn("Error while loading data for " .. plr.Name .. ": " .. Err) -- Send error message
	else -- If it didn't error
		print("Data for " .. plr.Name .. " loaded successfully.") -- Sends success message
	end
	
	--// END
	
end

--// SAVE DATA FUNCTION

function module.SaveData(plr)
	
	--// VARIABLES
	local Key = plr.UserId -- Key for DataStore
	local Stats = plr:WaitForChild("leaderstats") -- Player stats
	local Coins = Stats:WaitForChild("Coins") -- Coins
	local rPlayer = game:GetService("ReplicatedStorage").Players:WaitForChild(plr.Name) -- ReplicatedStorage Player
	
	local Success, Err = pcall(function() -- Pcall incase an error occurs
		
		--// REGULAR DATA
		
		local ValuesToSave = {
			
			Coins = Coins.Value,
			ToolEquipped = rPlayer.ToolEquipped.Value,
			BackpackEquipped = rPlayer.BackpackEquipped.Value
			
		}
		
		Player_Data:SetAsync(Key, ValuesToSave) -- Saves Data
		
		--// TOOLS OWNED
		
		local ToolsOwnedTable = {} -- Creates a table for tools to be stored in
		
		for _,v in pairs(rPlayer.ToolsOwned:GetChildren()) do -- Iterates through the player's tools

			if v and game:GetService("ReplicatedStorage").Tools:FindFirstChild(v.Name) then -- Checks if tool exists
				
				table.insert(ToolsOwnedTable, v.Name) -- Inserts it to a table
				
			end

		end
		
		ToolsOwned:SetAsync(Key, ToolsOwnedTable) -- Saves Data

		--// BACKPACKS OWNED
		
		local BackpacksOwnedTable = {} -- Creates a table for tools to be stored in
		
		for _,v in pairs(rPlayer.BackpacksOwned:GetChildren()) do -- Iterates through the player's tools

			if v and game:GetService("ReplicatedStorage").BackpacksOwned:FindFirstChild(v.Name) then -- Checks if tool exists
				
				table.insert(BackpacksOwnedTable, v.Name) -- Inserts it to a table
				
			end

		end
		
		BackpacksOwned:SetAsync(Key, BackpacksOwnedTable) -- Saves Data
		
	end)
	
	if not Success then -- Checks if it errored
		warn("Error while saving data for " .. plr.Name .. ": " .. Err) -- Send error message
	else -- If it didn't error
		print("Data for " .. plr.Name .. " saved successfully.") -- Sends success message
	end
	
	--// END
	
end

--// PLAYER LEFT FUNCTION

function module.PlayerLeft(rPlr)
	rPlr:Destroy()
end

return module

Any contributions are greatly appreciated! (:

Apparently this issue has emerged a long time ago, they appear randomly, especially during weekends. This kind of error doesn’t need any change from the game itself(except sending a warning to players that DataStores failed to save). It will resolve itself eventually.

Did some research and the problem is very inconsistent. It might be at Roblox’s end, which we cannot resolve by our own hands.

You should have data store error handling implementation in place which handles errors.

example:

local save_these_player_ids_table = {}
local player_data  = {} --[playerid] = data ~ for each player

function save()
for x = 1, #save_these_player_ids_table do
--attempt to SetAsync(save_table[x], player_data[save_table[x]])
--if success then remove player id from save_these_player_ids_table
end

function add_player(playerid, data) --generic example
player_data[playerid] = data
end

function player_leaving(player)
table.insert(save_these_player_ids_table, player.UserId)
end

while true do
wait(60)
save()
end

In a perfect world, you wouldn’t have to worry about data store errors, but in all reality, the example I made above should handle some saving problems.

Note: In my example, save_table is referring to save_these_player_ids_table in case that was confusing