Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
3

DataStore request was added to queue. If request queue fills, further Try sending fewer requests??

Asked by 2 years ago
Edited 2 years ago

Hi I keep receiving this error on my House Data Store system: DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key. Script:

001local DataStoreService = game:GetService("DataStoreService")
002 
003local MainData = DataStoreService:GetDataStore("MainData")
004 
005local HouseData = DataStoreService:GetDataStore("HouseData")
006 
007--Variables--
008 
009function saveHouseData(player)
010 
011 
012 
013    local Houses = {}
014 
015    for i, value in pairs(player.Houses:GetChildren()) do
View all 115 lines...

Updated

I got rid of all errors datastore still doesn't work here is the updated code

001local DataStoreService = game:GetService("DataStoreService")
002 
003local MainData = DataStoreService:GetDataStore("MainData")
004 
005local HouseData = DataStoreService:GetDataStore("HouseData")
006 
007 
008 
009local Players = game:GetService("Players")
010 
011local ReplicatedStorage = game:GetService("ReplicatedStorage")
012 
013local RunService = game:GetService("RunService")
014 
015 
View all 219 lines...
0
Sorry about the spacing I sent the code to my other computer to post it and the format gets weird theking66hayday 841 — 2y

1 answer

Log in to vote
2
Answered by 2 years ago
Edited 2 years ago

Solution

This is where RequestBudget comes in. If there isn't enough RequestBudget, it will show that warning. To fix that, you will need to wait until there is enough budget.

1local function waitForRequestBudget(requestType: Enum.DataStoreRequestType)
2    local currentBudget = DataStoreService:GetRequestBudgetForRequestType(requestType)
3    while currentBudget < 1 do
4        currentBudget = DataStoreService:GetRequestBudgetForRequestType(requestType)
5        task.wait(5)
6    end
7end

Now you can use that function in GetAsync() and SetAsync().

1-- House Data --
2waitForRequestBudget(Enum.DataStoreRequestType.GetAsync)
3local houseData = HouseData:GetAsync(player.UserId) or {}
4 
5-- House Saving --
6waitForRequestBudget(Enum.DataStoreRequestType.SetAsync)
7HouseData:SetAsync(player.UserId, Houses)

Pcall (Protected Call)

I recommend using a pcall() when using an asynchronous function since they can error and break the script. pcall() calls a function and if it errors, it won't affect the script and the error message will just get returned by pcall(). If it didn't error and it was successful, pcall() will return everything returned by the called function.

01-- House Data --
02waitForRequestBudget(Enum.DataStoreRequestType.GetAsync)
03 
04local success, houseData = pcall(function()
05    return HouseData:GetAsync(player.UserId)
06end)
07-- or
08local success, houseData = pcall(HouseData.GetAsync, HouseData, player.UserId)
09 
10if success == true then -- if successful
11    for houseName, houseValue in pairs(HouseData)
12        Houses[houseName].Value = houseValue
13    end
14else -- if it errors (mostly when player has no data)
15    print("Player " .. Player.Name .. " has no data!")
16    warn(houseData) -- warns the error message
17end

Retries

If you use SetAsync() once, there's a chance it might error, not saving the data. What you can do is retry until data is saved.

1-- House Saving --
2local success
3repeat
4    waitForRequestBudget(Enum.DataStoreRequestType.SetAsync)
5    success = pcall(HouseData.SetAsync, HouseData player.UserId, Houses)
6until success == true

UpdateAsync > SetAsync

UpdateAsync() is safer to use in multi-server attempts than SetAsync(), so you should use it except when using an OrderedDataStore (commonly used in global leaderboards).

1-- House Saving --
2local success
3repeat
4    waitForRequestBudget(Enum.DataStoreRequestType.UpdateAsync)
5    success = pcall(HouseData.UpdateAsync, HouseData, player.UserId, function()
6        return Houses
7    end)
8until success == true

Final Script

001local DataStoreService = game:GetService("DataStoreService")
002local MainData = DataStoreService:GetDataStore("MainData")
003local HouseData = DataStoreService:GetDataStore("HouseData")
004 
005local Players = game:GetService("Players")
006local ReplicatedStorage = game:GetService("ReplicatedStorage")
007local RunService = game:GetService("RunService")
008 
009local function waitForRequestBudget(requestType: Enum.DataStoreRequestType)
010    local currentBudget = DataStoreService:GetRequestBudgetForRequestType(requestType)
011    while currentBudget < 1 do
012        currentBudget = DataStoreService:GetRequestBudgetForRequestType(requestType)
013        task.wait(5)
014    end
015end
View all 108 lines...

Source

0
It still doesn't work. I edited the script a bit to fix somethings. Errors: First error is when a player doesn't have a plot claimed and buys a house and then leaves error code line 123 ServerScriptService.DataManager:121: attempt to index nil with 'CurrentOwner' but if a player does have plot claimed and buys house then leaves no errors come up and won't save data though theking66hayday 841 — 2y
0
I updated my post with the new code if you can have look at it -- Thanks theking66hayday 841 — 2y
0
I got rid of all the errors but datastore doesn't work still theking66hayday 841 — 2y
0
OH T3_MasterGamer 2189 — 2y
View all comments (2 more)
0
The error was on line 76 and I forgot to removed "function(" so I changed my answer and removed it. T3_MasterGamer 2189 — 2y
0
ok now I keep getting error on line 38 ServerScriptService.DataManager:38: invalid argument #1 to 'pairs' (table expected, got Instance) theking66hayday 841 — 2y
Ad

Answer this question