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

Data Store Gives Warns Requests Were Throttled?

Asked by 5 years ago

Hello! I was following a Data Store tutorial that I coincidentally found on this website. I made a few modifications to this to better suit my needs however whenever Money is changed, I receive a warning in the output log Request was throttled. Try sending fewer requests. Key = uid_70241310. The data store still saves values however I am not sure from where this warning is coming from in my script.

local DSS = game:GetService("DataStoreService")

local datastore = DSS:GetDataStore("GeneralSaveData", "Players")

function generateDataKey(player)
    local ret = "uid_" .. player.userId
    return ret
end

function generateDataTable(player)
    local dataTable = {
        Money = player.Money.Value
    }
    return dataTable
end

function saveDataForPlayer(player)
    local key = generateDataKey(player)
    local data = generateDataTable(player)
    datastore:SetAsync(key, data)
end

function inputDataToPlayer(player, data)
    player.Money.Value = data.Money          
end

function loadDataForPlayer(player)
    local key = generateDataKey(player)
    local data = datastore:GetAsync(key)
    inputDataToPlayer(player, data)          
end

game.Players.PlayerAdded:connect(function(player)
    local money = Instance.new("IntValue")
    money.Name = 'Money'
    money.Parent = player   

    loadDataForPlayer(player)
    player.Money.Changed:connect(function()
        saveDataForPlayer(player)
    end)
end)

game.Players.PlayerRemoving:connect(saveDataForPlayer)
0
You should not save data in a changed event you have no control over how many times it will run. User#5423 17 — 5y
0
Alright, I removed it and now I do not receive a warning. Thanks for the help! BunnyFilms1 297 — 5y

2 answers

Log in to vote
2
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
5 years ago

A Data Request is throttled when:

1.) You're sending too many requests for other players that goes over the requested function's limit

2.) You're sending data requests more than once on the same key without a six-second cooldown

When the player joins, you're calling loadDataForPlayer which will change the stats of the player. It will of course fire the Changed event to save the data without a six-second cooldown. That's where the throttling occurs

Ad
Log in to vote
0
Answered by 5 years ago

This happens because you change the money value too fast.

Answer this question