I don't see any errors when ever I play my game through the site but it still doesn't work
Here's my script :
local DataStore = Game:GetService("DataStoreService"):GetDataStore("Level") local Requests = 0 local Max = 60 function Good() return Requests <= Max end function UpdateMax() Max = 60 + 10 * #Game.Players:GetPlayers() end Game.Players.PlayerAdded:connect(function(Player) local Stat = Player:WaitForChild("stats"):WaitForChild("Level") Stat.Value = DataStore:GetAsync(Player.userId) Stat.Changed:connect(function() if Good() then DataStore:SetAsync(Player.userId,Stat.Value) Requests = Requests + 1 end end) end) Game.Players.PlayerRemoving:connect(function() UpdateMax() end) Spawn(function() while wait(60) do Requests = 0 end end)
You never call UpdateMax()
when a new player joins.
Secondly, I'm not entirely sure about Spawn(). I never use it, so I wouldn't trust it. I would suggest just using a normal coroutine.
Also, when you call :GetAsync()
you never increase requests. Get requests DO use part of your allowed request quota.
local DataStore = Game:GetService("DataStoreService"):GetDataStore("Level") local Requests = 0 local Max = 60 function Good() return Requests <= Max end function UpdateMax() Max = 60 + 10 * #Game.Players:GetPlayers() end Game.Players.PlayerAdded:connect(function(Player) UpdateMax() local Stat = Player:WaitForChild("stats"):WaitForChild("Level") Stat.Value = DataStore:GetAsync(Player.userId) Requests = Requests + 1; Stat.Changed:connect(function() if Good() then DataStore:SetAsync(Player.userId,Stat.Value) Requests = Requests + 1 end end) end) Game.Players.PlayerRemoving:connect(function() UpdateMax() end) coroutine.resume(coroutine.create(function() while wait(60) do Requests = 0 end end))