local leveldata = game:GetService("DataStoreService"):GetDataStore("level")
local EXPdata = game:GetService("DataStoreService"):GetDataStore("EXP")
local xpLeveldata = game:GetService("DataStoreService"):GetDataStore("xpLevel")
local Golddata = game:GetService("DataStoreService"):GetDataStore("Gold")
function savedata(dataname, playerid, value)
game:GetService("DataStoreService"):GetDataStore(dataname):SetAsync(playerid, value)
end
game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local gold = Instance.new("IntValue")
gold.Value = Golddata:GetAsync(tostring(player.userId))
gold.Name = "Gold"
gold.Parent = leaderstats
gold.Value = 500
local level = Instance.new("IntValue")
level.Value = leveldata:GetAsync(tostring(player.userId)) or 1
level.Name = "Level"
level.Parent = leaderstats
level.Value = 1
local EXP = Instance.new("IntValue")
EXP.Value = EXPdata:GetAsync(tostring(player.userId))
EXP.Parent = player
EXP.Name = "Exp"
local xpLevel = Instance.new("IntValue")
xpLevel.Value = xpLeveldata:GetAsync(tostring(player.userId)) or 500
xpLevel.Value = 500
xpLevel.Name = 'ExpNeeded'
xpLevel.Parent = player
EXP.Changed:connect(function()
if player:WaitForChild('Exp').Value >= player:WaitForChild('ExpNeeded').Value then
level.Value = level.Value + 1
xpLevel.Value = xpLevel.Value + (xpLevel.Value/2)
EXP.Value = 0
savedata('leveldata',player.userId,level.Value)
savedata('EXPdata',player.userId,EXP.Value)
savedata('xpLeveldata',player.userId,xpLevel.Value)
savedata('Golddata',player.userId,gold.Value)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
savedata('leveldata',player.userId,player.leaderstats.Level.Value)
savedata('EXPdata',player.userId,player.EXP.Value)
savedata('xpLeveldata',player.userId,player.ExpNeeded.Value)
savedata('Golddata',player.userId,player.leaderstats.Gold.Value)
end)
so this is my code in my leaderstats but every time i kill an enemy and get EXP it says "Request was throttled. Try sending fewer requests. Key = 306209.
I dont feel as if i am requesting that many for it to throttle?

2 comments
can i ask specifically what you mean by "writing" a key?
For instance, if I were to DataStore:SetAsync(key1) and then right after do DataStore:SetAsync(key2), that would be fine as they are two different keys. However, trying to do DataStore:SetAsync(key1) then DataStore:SetAsync(key1) again after 1 second would fail, because it's the same key (key1). Does that make more sense?