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

DataStore request was added to queue?

Hello,

I am trying to create a script which saves time played. Everything works fine except for this warning:

"DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = 36352854".

This is the script that saves the time played

local DataStore = game:GetService('DataStoreService');
local TimeSave = DataStore:GetDataStore('test');

local function SavePlayerData(Time,userId)
	TimeSave:UpdateAsync(userId,function(oldValue)
		return Time;
    end);
end;

game.Players.PlayerAdded:connect(function(plr)
	local Leaderstats = Instance.new('IntValue',plr); Leaderstats.Name = 'leaderstats';
	local Time_Played = Instance.new('IntValue',Leaderstats); Time_Played.Name = 'Minutes Played';
	
	local Success,Fail = pcall(function() 
		TimeSave:GetAsync(plr.UserId);
	end);
	
	if Success then 
		Time_Played.Value = TimeSave:GetAsync(plr.UserId);
	else
		Time_Played.Value = 0;
	end;
	
	spawn(function()
		while wait(60) and (Time_Played ~= nil) do
			Time_Played.Value = Time_Played.Value + 1;
			SavePlayerData(Time_Played.Value,plr.UserId);
		end;
	end);
end);

game.Players.PlayerRemoving:Connect(function(plr)
	SavePlayerData(plr.leaderstats['Minutes Played'].Value,plr.UserId);
end);

game:BindToClose(function() 
	for _, player in ipairs(game.Players:GetPlayers()) do
		SavePlayerData(player.leaderstats['Minutes Played'].Value,player.UserId);
	end;
end);

How can I fix this warning?

1 answer

✓ Accepted answer

There's a limit on datastore requests you can make. If you go over these limits this warning will appear and your requests will be retried later. However if you keep sending too much even after the queue is full it will start dropping them as indicated.

You can see the exact limits here: https://developer.roblox.com/en-us/articles/Datastore-Errors

1 comment

0

Thanks!

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