So ive been experimenting with Data Stores for some time now. And i recently saw that someone used this in their code to wait for enough budget(Cant link original post since i cant find it). So i was wondering if this is a good or bad way to wait for enough budget??
Module code:
local function GetNumPlrs()
if #game.Players:GetPlayers() == 0 then
return 1
else
return #game.Players:GetPlayers()
end
end
local function GetBudget(Type)
return Service:GetRequestBudgetForRequestType(Type) -- // Service is the DataStore
end
local function WaitForBudget(Type)
local Budget = nil
local Max = 0
repeat
Max = 60 + GetNumPlrs() * 10
task.wait()
until GetBudget(Type) >= Max
end
function module:Get(Key)
local Max = 60 + GetNumPlrs() * 10
if GetBudget(Enum.DataStoreRequestType.GetAsync) < Max then
WaitForBudget()
end
end
Any help would be really appreciated 