I keep getting this error that says "Datastore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests." Every time I stop the game. I don't know what I did wrong. Can someone help me? Thanks.
local player = game:GetService("Players") local dataStoreService = game:GetService("DataStoreService") local saveDataStore = dataStoreService:GetDataStore("ObbyDataSave1") local function savePlrData(plr) local success,err = pcall(function() local saveData = {} for _,stat in pairs(plr.leaderstats:GetChildren())do saveData[stat.Name] = stat.Value end saveDataStore:SetAsync(plr.UserId,saveData) end) if not success then return err end end player.PlayerAdded:connect(function(plr) local stats = Instance.new("Folder") stats.Name = "leaderstats" stats.Parent = plr local stage = Instance.new("IntValue") stage.Name = "Stage" stage.Parent = stats local data = saveDataStore:GetAsync(plr.UserId) if data then print(data.Stage) for _,stat in pairs(stats:GetChildren()) do stat.Value = data[stat.Name] end else print(plr.Name .. " has no data") end plr.CharacterAdded:connect(function(char) local humanoid,hrp = char:WaitForChild("Humanoid"),char:WaitForChild("HumanoidRootPart") wait() if humanoid and hrp then if stage.Value ~= 0 then local part = workspace.ObbyStages:FindFirstChild(stage.Value) hrp.CFrame = part.CFrame + Vector3.new(0,1,0) end end end) end) player.PlayerRemoving:connect(function(plr) local err = savePlrData(plr) if err then print(err) end end) game:BindToClose(function() for _,plr in pairs(player:GetPlayers()) do local err = savePlrData(plr) if err then print(err) end end wait(2) end)
Maybe its because when the testing player is removed, it saves their data, and when the game binds to close, it saves their data again? Otherwise, you cannot remove or change the datastore request limit AFAIK unfortunately.