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
You should not save data in a changed event you have no control over how many times it will run.
Alright, I removed it and now I do not receive a warning. Thanks for the help!