I heard that it takes a wait time of 6 seconds to SetAsync a players data. But I am trying to set ALL of the player's data before as the player is removed. But I am stuck on what to do here..
Module script:
return { PlayerData = { Coins = 0, Diamonds = 0, Experience = 0, Kills = 0, Level = 0, EXPneeded = 0, } }
script:
local DataStore = game:GetService("DataStoreService"):GetOrderedDataStore("PlayerDataV1"); local DataModule = require(game.ReplicatedStorage.PlayerData) game.Players.PlayerAdded:Connect(function(plr) for i, v in pairs(DataModule.PlayerData) do DataModule.PlayerData[i] = DataStore:GetAsync(plr.UserId, i) -- this is good. end end) game.Players.PlayerRemoving:Connect(function(plr) for i, v in pairs(DataModule.PlayerData) do DataModule.PlayerData['Coins'] = DataStore:SetAsync(plr.UserId, DataModule.PlayerData['Coins']) --[[ DataModule.PlayerData['Diamonds'] = DataStore:SetAsync(plr.UserId, DataModule.PlayerData['Diamonds']) DataModule.PlayerData['Experience'] = DataStore:SetAsync(plr.UserId, DataModule.PlayerData['Experience']) DataModule.PlayerData['Kills'] = DataStore:SetAsync(plr.UserId, DataModule.PlayerData['Kills']) DataModule.PlayerData['Level'] = DataStore:SetAsync(plr.UserId, DataModule.PlayerData['Level']) DataModule.PlayerData['EXPneeded'] = DataStore:SetAsync(plr.UserId, DataModule.PlayerData['EXPneeded']) ]]-- I want to add the rest of these without throttle. end end)
Try storing all of your player data in one dictionary that can be posted to SetAsync in one call.
From looking at your system, that may require a rewrite.
You don't want to store everything within individual tables, across players, but instead have each player have one table that has tables inside of it with the appropriate values in place.
Structured like so:
Player.Name Coins 1400 Diamonds 2000 Experience 67920