Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Data Store Gives Warns Requests Were Throttled?

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)

2 comments

0

You should not save data in a changed event you have no control over how many times it will run.

0

Alright, I removed it and now I do not receive a warning. Thanks for the help!

2 answers

✓ Accepted answer

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

This happens because you change the money value too fast.

This discussion is preserved as it was. New answers, comments, and votes are closed.