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

Anyone how do i fix this DataStore request was added to queue?

Asked by 3 years ago
Edited by JesseSong 3 years ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).

So I'm making my game but when they touched the winpad IDK wth happened the points suddenly didn't add a +1 point and the error will pop up DataStore request was added to the queue. If the request queue fills, further requests will be dropped. Try sending fewer requests. how do I fix it sorry I'm new at DataStores? Here's my script:

Script on ServerScriptService:

local ds = game:GetService("DataStoreService")
local bool = ds:GetDataStore("BoolSaving5")

game.Players.PlayerAdded:Connect(function(plr)
    local boolValue = Instance.new("BoolValue")
    boolValue.Parent = plr
    boolValue.Name = "BoolValue"

    local boolValue1 = Instance.new("BoolValue")
    boolValue1.Parent = plr
    boolValue1.Name = "BoolValue1"

    local boolValue2 = Instance.new("BoolValue")
    boolValue2.Parent = plr
    boolValue2.Name = "BoolValue2"

    local boolValue3 = Instance.new("BoolValue")
    boolValue3.Parent = plr
    boolValue3.Name = "BoolValue3"

    local boolValue4 = Instance.new("BoolValue")
    boolValue4.Parent = plr
    boolValue4.Name = "BoolValue4"

    local boolValue5 = Instance.new("BoolValue")
    boolValue5.Parent = plr
    boolValue5.Name = "BoolValue5"

    local boolValue6 = Instance.new("BoolValue")
    boolValue6.Parent = plr
    boolValue6.Name = "BoolValue6"

    local boolValue7 = Instance.new("BoolValue")
    boolValue7.Parent = plr
    boolValue7.Name = "BoolValue7"

    local boolValue8 = Instance.new("BoolValue")
    boolValue8.Parent = plr
    boolValue8.Name = "BoolValue8"

    local boolValue9 = Instance.new("BoolValue")
    boolValue9.Parent = plr
    boolValue9.Name = "BoolValue9"

    local boolValue10 = Instance.new("BoolValue")
    boolValue10.Parent = plr
    boolValue10.Name = "BoolValue10"

    local boolValue11 = Instance.new("BoolValue")
    boolValue11.Parent = plr
    boolValue11.Name = "BoolValue11"

    boolValue.Value = bool:GetAsync(plr.UserId) or false
    boolValue1.Value = bool:GetAsync(plr.UserId) or false
    boolValue2.Value = bool:GetAsync(plr.UserId) or false
    boolValue3.Value = bool:GetAsync(plr.UserId) or false
    boolValue4.Value = bool:GetAsync(plr.UserId) or false
    boolValue5.Value = bool:GetAsync(plr.UserId) or false
    boolValue6.Value = bool:GetAsync(plr.UserId) or false
    boolValue7.Value = bool:GetAsync(plr.UserId) or false
    boolValue8.Value = bool:GetAsync(plr.UserId) or false
    boolValue9.Value = bool:GetAsync(plr.UserId) or false
    boolValue10.Value = bool:GetAsync(plr.UserId) or false
    boolValue11.Value = bool:GetAsync(plr.UserId) or false
end)

game.Players.PlayerRemoving:Connect(function(plr)
    bool:SetAsync(plr.UserId, plr.BoolValue.Value)
    bool:SetAsync(plr.UserId, plr.BoolValue1.Value) -- Duplitcate more if you want more winpad and remember to change into a different name (it has to be the same as the name in the script in the winpad)
    bool:SetAsync(plr.UserId, plr.BoolValue2.Value)
    bool:SetAsync(plr.UserId, plr.BoolValue3.Value)
    bool:SetAsync(plr.UserId, plr.BoolValue4.Value)
    bool:SetAsync(plr.UserId, plr.BoolValue5.Value)
    bool:SetAsync(plr.UserId, plr.BoolValue6.Value)
    bool:SetAsync(plr.UserId, plr.BoolValue7.Value)
    bool:SetAsync(plr.UserId, plr.BoolValue8.Value)
    bool:SetAsync(plr.UserId, plr.BoolValue9.Value)
    bool:SetAsync(plr.UserId, plr.BoolValue10.Value)
    bool:SetAsync(plr.UserId, plr.BoolValue11.Value)
    end)

local DataStoreService = game:GetService("DataStoreService")

local playerData = DataStoreService:GetDataStore("PlayerData5")



local function onPlayerJoin(player)  -- Runs when players join

    local leaderstats = Instance.new("Folder")  --Sets up leaderstats folder

    leaderstats.Name = "leaderstats"

    leaderstats.Parent = player



    local Rooms = Instance.new("IntValue") --Sets up value for leaderstats

    Rooms.Name = "Rooms"

    Rooms.Parent = leaderstats







    local playerUserId = "Player_" .. player.UserId  --Gets player ID

    local data = playerData:GetAsync(playerUserId)  --Checks if player has stored data

    if data then

        Rooms.Value = data['Rooms']


    else

        -- Data store is working, but no current data for this player

    Rooms.Value = 0



    end

end


Another Script on it:
local function create_table(player)

    local player_stats = {}

    for _, stat in pairs(player.leaderstats:GetChildren()) do

        player_stats[stat.Name] = stat.Value

    end

    return player_stats

end



local function onPlayerExit(player)  --Runs when players exit



    local player_stats = create_table(player)

    local success, err = pcall(function()

        local playerUserId = "Player_" .. player.UserId

        playerData:SetAsync(playerUserId, player_stats) --Saves player data

    end)



    if not success then

        warn('Could not save data!')

    end

end



game.Players.PlayerAdded:Connect(onPlayerJoin)

game.Players.PlayerRemoving:Connect(onPlayerExit)

seriously appreciate any help. Thanks.

1
To actually follow the answers you've been given, you'll need to put all the values you want saved in a single table. You can look up examples of how to do this in other data store scripts. chess123mate 5873 — 3y
0
Yea, like @chess123mate said, put it in a table, as it saves a lot of time JesseSong 3916 — 3y

2 answers

Log in to vote
0
Answered by
JesseSong 3916 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

The error essentially means that you're sending too many requests very quickly and hence causes the error. To fix this, you simply to SetAsync with an argument of the amount of time you want it to save, so that there are no issues in-game.

Source:

Dev Forums

Scripting Helpers

Ad
Log in to vote
0
Answered by 3 years ago

yeah, youre absolutely spamming datastore which is why youre getting that warning limit the amount you send a set/get request to roblox datastore to stop those warnings from popping up

Answer this question