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 warning?

is this why my datastore doesnt work? No Errors Its a Warning

local DSService = game:GetService("DataStoreService"):GetDataStore("Normalslots")

game.Players.PlayerAdded:Connect(function(player)
	local uniquekey = "id-"..player.userId
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local Clicks = Instance.new("IntValue", leaderstats)
	Clicks.Name = "Clicks"
	Clicks.Value = 0

	local Prestiges = Instance.new("IntValue", leaderstats)
	Prestiges.Name = "Prestiges"
	Prestiges.Value = 0

	local Coins = Instance.new("IntValue", leaderstats)
	Coins.Name = "Coins"
	Coins.Value = 0

	local GetSaved = DSService:GetAsync(uniquekey)
	if GetSaved then
		Clicks.Value = GetSaved[1]
		Prestiges.Value = GetSaved[2]
		Coins.Value = GetSaved[3]
	else
		local NumbersForSaving = {Clicks.Value, Prestiges.Value, Coins.Value}
		DSService:SetAsync(uniquekey,NumbersForSaving)
	end
end)

game.Players.PlayerRemoving:connect(function(player)
	local uniquekey = "id-"..player.userId
	local Savetable = {player.leaderstats.Clicks.Value, player.leaderstats.Prestiges.Value, player.leaderstats.Coins.Value}
	DSService:SetAsync(uniquekey,Savetable)

game:BindToClose(function()
	local RS = game:GetService('RunService')
	if RS:IsStudio() then return end
	for _, player in ipairs(game.Players:GetPlayers()) do
	    end
	end)
end)

2 comments

0

Why can't you search that on google? Literally 20 posts on that. Anyway, datastores have a limit, and when that limit is reached, roblox throws that warning.

0

agree, there are actually more than 20 posts on this, like half a billion

1 answer

✓ Accepted answer

It will not cause problems in your case, the reason why this is happening is because you have both PlayerRemoving and BindToClose functions and since you are probably playtesting alone, the two functions fire at the same time. If you use SetAsync, UpdateAsync, etc... more than once per 6 seconds, it will warn you that you should slow down, to completely break the data store you need to send this 60 + numPlayers × 10 many requests on the same data store (source).

You can fix it (Even tho you don't have to). Since PlayerRemoving fires before BindToClose, you can check if data was saved during the function and if it did then add the Player into some sort of table in which on BindToClose you can check if the player has the data saved, although this won't be working 100% of time because BindToClose can fire before you add the Player into the table.

I personally fix it with metatables but i guess (By looking at your script) they will be too hard for you. I create a metatable in which the player has stored all of the information about him and there are those 2 bool values which mean: DataSaved (Whether the player had data saved successfully) and DataSaving which is a BindableEvent which will wait until PlayerRemoving function finishes and then it will check if DataSaved was set to true, if it did then it will return, else it will try to save the data once again.

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