Full Error: DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = 1137780701

Why do I get this? It prints out data saved every time but it doesn't actually save data unless you change the value manually (meaning when it gets changed through a local script it doesn't save), the issue might be causing this.

here's my script:

local DataStoreService = game:GetService("DataStoreService")
local dataStore = DataStoreService:GetDataStore("DevelopemntDataV1.1") -- change this to wipe player's data
local hourwait = 24
local possiblerewards = {}
local timenow = tick()
--[[
local Event = Instance.new("RemoteEvent")
Event.Name = "ClickEvent"
Event.Parent = game:GetService("ReplicatedStorage")
--]]
local newThread = coroutine.wrap(function()
	while wait(15) do
		for i, v in ipairs(game:GetService("Players"):GetPlayers()) do
			saveData(v)
		end
	end
end)

function saveData(player)
	--[[
	local lifetimevalue = player.PlayerValues.LifetimeStats.LifetimeClicks.Value
	local storedValue = lifetimevalue ~= 0 and math.floor(math.log(lifetimevalue) / math.log(1.0000001)) or 0
	local lifetimevalue = player.PlayerValues.LifetimeStats.LifetimeGems.Value
	local storedValue2 = lifetimevalue ~= 0 and math.floor(math.log(lifetimevalue) / math.log(1.0000001)) or 0
	--]]
	local tableToSave = {
		player.leaderstats.Flips.Value;
		player.leaderstats.Money.Value;
	}

	local success, err = pcall(function()
		dataStore:SetAsync(player.UserId, tableToSave)
	end)

	if success then
		print("Data has been saved!")
	else
		print("Data hasn't been saved!")
		warn(err)		
	end
end

game.Players.PlayerAdded:Connect(function(player)
	
	local leaderstats = Instance.new("Folder",player)
	leaderstats.Name = "leaderstats"
	
	local Flips = Instance.new("IntValue",leaderstats)
	Flips.Name = "Flips"
	Flips.Parent = leaderstats
	
	local Money = Instance.new("IntValue",leaderstats)
	Money.Name = "Money"
	Money.Parent = leaderstats
	
	local data

	local success, err = pcall(function()

		data = dataStore:GetAsync(player.UserId)

	end)

	local values = { -- change this to the values you want
		Flips;
		Money;
	}
	if success then
		--[[
		Flips.Value = data[1]
		Money.Value = data[2]--]]
		--[[
		Rebirth.Value = data[3]
		Tokens.Value = data[4]
		Multiplier.Value = data[5]
	--]]
		try, except = pcall(function()
			for i,v in pairs(data)do
				local suc, err = pcall(function()
					values[i].Value = v
				end)
				if not suc then
					print(suc)
					warn(err)
					print(try)
					warn(except)
				end
			end
		end)
	end
end)

game.Players.PlayerRemoving:Connect(function(player)
	local success, err  = pcall(function()
		saveData(player)
	end)

	if success then
		print("Data has been saved")
	else
		print("Data has not been saved!")
		warn(err)
	end
end)

game:BindToClose(function()
	for _, player in pairs(game.Players:GetPlayers()) do
		local success, err  = pcall(function()
			saveData(player)
		end)

		if success then
			print("Data has been saved")
		else
			print("Data has not been saved!")
			warn(err)
		end
	end
end)

local e = {
	[1]={
		""}
}
warn(e[1])
while wait(1) do
	if not (#game.Players:GetPlayers() <= 0) then
		break
	end
end
newThread()
print("Datastore time: ".. tostring(tick() - timenow) .." seconds")

2 comments

0

Don't panic. It's not entirely your fault!

Instead this could be caused by multiple factors, including the workload Roblox's servers are handling.

I suggest using a module like datastore2 to prevent data loss, and perhaps increasing the time before the interval saves from 15, to 60.

0

you don't need to save every 15 seconds if you save when the player leaves