I'm trying to save the Data on my game but i got this error ! https://gyazo.com/6cfcea777ab4454106b944af82fd1ead
I don't know how to fix that so if u know help me ..
local level = 1
local exp = 0
local axp = 20
local strength = 0
local defense = 0
local psypower = 0
local point = 0
local InStudio = game:GetService("RunService"):IsStudio()
if not InStudio then
level = game:GetService("DataStoreService"):GetDataStore("Levels")
exp = game:GetService("DataStoreService"):GetDataStore("EXP")
axp = game:GetService("DataStoreService"):GetDataStore("AXP")
defense = game:GetService("DataStoreService"):GetDataStore("defense")
strength = game:GetService("DataStoreService"):GetDataStore("strength")
psypower = game:GetService("DataStoreService"):GetDataStore("psypower")
point = game:GetService("DataStoreService"):GetDataStore("point") -- Amount of exp needed to level up.
end
function savedata(dataname, playerid, value)
if InStudio then return end
dataname:SetAsync(playerid, value)
end
game.Players.PlayerAdded:connect(function(player)
local leader = Instance.new("Folder")
leader.Name = "leaderstats"
leader.Parent = player
local levelz = Instance.new("IntValue")
levelz.Name = "Level"
local xpz = Instance.new("NumberValue")
xpz.Name = "Exp"
local xpn = Instance.new("IntValue")
xpn.Name = "ExpNeeded"
local defz = Instance.new("NumberValue")
defz.Name = "Defense"
local psyz = Instance.new("NumberValue")
psyz.Name = "PsyPower"
local stz = Instance.new("NumberValue")
stz.Name = "Strength"
local pointsz = Instance.new("NumberValue")
pointsz.Name = "Points"
if not InStudio then
xpn.Value = axp:GetAsync(tostring(player.userId)) or 20
xpz.Value = exp:GetAsync(tostring(player.userId)) or 0
levelz.Value = level:GetAsync(tostring(player.userId)) or 1
stz.Value = strength:GetAsync(tostring(player.userId)) or 0
defz.Value = defense:GetAsync(tostring(player.userId)) or 0
psyz.Value = psypower:GetAsync(tostring(player.userId)) or 0
pointsz.Value = point:GetAsync(tostring(player.userId)) or 0
else
xpn.Value = axp
xpz.Value = exp
levelz.Value = level
stz.Value = strength
defz.Value = defense
psyz.Value = psypower
pointsz.Value = point
end
levelz.Parent = leader
xpz.Parent = leader
xpn.Parent = leader
stz.Parent = leader
defz.Parent = leader
psyz.Parent = leader
pointsz.Parent = leader
xpz.Changed:connect(function()
if player.leaderstats:WaitForChild("Exp").Value >= player.leaderstats:WaitForChild("ExpNeeded").Value then
levelz.Value = levelz.Value + 1
pointsz.Value = pointsz.Value + 3
player.Character.Humanoid.MaxHealth = player.Character.Humanoid.MaxHealth +1
player.Character.Humanoid.Health = player.Character.Humanoid.Health +1
--[[Here's a cool formula you can try out for higher exp
n = level
a = exp required to level up
a = ((n(n+1)/2)*100
]]
xpn.Value = math.floor(xpn.Value +500 ) --You can change this if you want.
xpz.Value = 0
wait(1)
savedata(level, player.userId, levelz.Value)
savedata(exp, player.userId, xpz.Value)
savedata(axp, player.userId, xpn.Value)
savedata(strength, player.userId, stz.Value)
savedata(defense, player.userId, defz.Value)
savedata(psypower, player.userId, psyz.Value)
savedata(point, player.userId, pointsz.Value)
else
savedata(level, player.userId, levelz.Value)
savedata(exp, player.userId, xpz.Value)
savedata(axp, player.userId, xpn.Value)
savedata(strength, player.userId, stz.Value)
savedata(defense, player.userId, defz.Value)
savedata(psypower, player.userId, psyz.Value)
savedata(point, player.userId, pointsz.Value)
end
savedata(level, player.userId, levelz.Value)
savedata(exp, player.userId, xpz.Value)
savedata(axp, player.userId, xpn.Value)
savedata(strength, player.userId, stz.Value)
savedata(defense, player.userId, defz.Value)
savedata(psypower, player.userId, psyz.Value)
savedata(point, player.userId, pointsz.Value)
end)
end)
game.Players.PlayerRemoving:connect(function(player)
savedata(level, player.userId, player.leaderstats.Level.Value)
savedata(exp, player.userId, player.leaderstats.Exp.Value)
savedata(axp, player.userId, player.leaderstats.ExpNeeded.Value)
savedata(strength, player.userId, player.leaderstats.Strength.Value)
savedata(defense, player.userId, player.leaderstats.Defense.Value)
savedata(psypower, player.userId, player.leaderstats.PsyPower.Value)
savedata(point, player.userId, player.leaderstats.Points.Value)
end)

3 comments
You're sending too many save requests for it to handle. It puts the other ones it cannot handle in a queue and saves them when it has taken care of the others. Try sending fewer requests.
Edit:- code block
Please don't use blank lines in between everywhere. It's also not an error just a warning. You're sending too many requests too fast exceeding the limit.