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)
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