The console gives me a throttle message and tells me to call it less. This functions managing these datastores have not been changed in a while and they've always worked but for some reason recently, it stopped working but only in my scripts. When I try to spam call it in the console like this it works perfectly fine and doesn't throttle
require(game.ServerScriptService._v2_GameManager._v2_PlayerManager._v2_PlayerDataManager)
:Get(game.Players.second_120, {"Wins", "WeeklyWins", "WinStreak", "Kills", "RoundsPlayed", "Coins", "Diamonds", "Level", "Experience", "GunSkins", "NameTags", "GunTypes", "Daily Reset"})
However, for some reason when I call my datastore functions like these two it throttles:
function PlayerDataManager:Get(player, statsRequested, statsRequestedDefaultOverrides)
print("Getting datastores")
print(statsRequested)
local statValues = {} -- table to be returned
for i, statRequestedName in ipairs(statsRequested) do
-- see if it is a valid stat
if table.find(validStatsNames, statRequestedName) == nil then
debug.traceback("Invalid stat requested. Requested for: " .. statRequestedName .. ", which is not a valid stat. Valid stats are: " .. table.concat(validStatsNames) .. ". Traceback: ")
end
-- Get stat object
local statRequested = validStats[table.find(validStatsNames, statRequestedName)]
-- Do stuff with datastore
print("start ds2 get")
local RequestedDataStore = DataStore2(statRequested.Name, player)
if statsRequestedDefaultOverrides == nil then
table.insert(statValues, i, RequestedDataStore:Get(statRequested.Default))
else
table.insert(statValues, i, RequestedDataStore:Get(statsRequestedDefaultOverrides[i]))
end
print("end ds2 get")
end
print("Got datastores")
return statValues
end
function PlayerDataManager:Increment(player, statsToIncrement, manualUpdate)
print("Increment datastore")
local statValues = {} -- table to be returned
for i, statToIncrement in ipairs(statsToIncrement) do
-- see if it is a valid stat
if table.find(validStatsNames, statToIncrement.Name) == nil then
debug.traceback("Invalid stat. Requested to change: " .. statToIncrement.Name .. ", which is not a valid stat. Valid stats are: " .. table.concat(validStatsNames) .. ". Traceback: ")
end
-- Get stat object
local statRequested = validStats[table.find(validStatsNames, statToIncrement.Name)]
print(statRequested)
-- Do stuff with datastore
local RequestedDataStore = DataStore2(statRequested.Name, player)
RequestedDataStore:Increment(statToIncrement.Increment, statRequested.Default)
-- Post-inc functions
--table.insert(statValues, i, {Name=statRequested.Name, Value=(RequestedDataStore:Get(statRequested.Default))})
print("incremented " .. statToIncrement.Name .. " by " .. statToIncrement.Increment)
if table.find(replicatedStatsNames, statToIncrement.Name) ~= nil then
ServerStorage.Players[player.Name][statToIncrement.Name].Value = RequestedDataStore:Get(statRequested.Default)
end
end
PostDataUpdate(player, statValues, manualUpdate)
print("Increments finished")
return statValues -- return in case we need the new value of the data
end
For example, the console tells me it's throttling when I call the get function from here
-- Get all player data
local playerData = PlayerDataManager:Get(player, {"Coins", "Diamonds", "Level", "Experience", "GunSkins", "NameTags", "GunTypes", "Daily Reset"})
print(playerData)
-- Load currency to gui
local playerGui = player.PlayerGui:WaitForChild("Lobby GUI")
-- Coins
ServerStorage.Players[player.Name].Coins.Value = playerData[1]
playerGui["CurrencyUI"]["Coin UI"]["Coin Value"].Text = playerData[1]
playerGui["CurrencyUI"]["Coin UI"]["Coin Value Background"].Text = playerData[1]
-- Diamonds
ServerStorage.Players[player.Name].Diamonds.Value = playerData[2]
playerGui["CurrencyUI"]["Diamond UI"]["Diamond Value"].Text = playerData[2]
playerGui["CurrencyUI"]["Diamond UI"]["Diamond Value Background"].Text = playerData[2]
--Load Experience
game.ReplicatedStorage.v2.GUIEvents.GetLevelFromExperience.OnServerInvoke = LevelTable.GetLevel
game.ReplicatedStorage.v2.GUIEvents.GetRewardFromLevel.OnServerInvoke = LevelTable.CheckForReward
ReplicatedStorage.v2.GUIEvents.UpdateVisuals:FireClient(player, {{Name="Experience", Value=playerData[4]}})
-- Load inventory
-- stuff
AccessoryPurchaseManager:Load(player, {playerData[5], playerData[6], playerData[7]})
