I’m using DataStore2. Loading player’s data takes a lot of time. Is there any way to speed up the load data?
local DataStore2 = require(game.ServerScriptService:WaitForChild("MainModule"))
local defaultValue = 0
game.Players.PlayerAdded:Connect(function(plr)
-- Main DataStore
local levelDataStore = DataStore2("level",plr)
local xpDataStore = DataStore2("xp",plr)
local cashDataStore = DataStore2("cash",plr)
local goldDataStore = DataStore2("gold",plr)
local higheststreakDataStore = DataStore2("higheststreak",plr)
local questcompletedDataStore = DataStore2("questcompleted",plr)
local obbiescompletedDataStore = DataStore2("obbiescompleted",plr)
local obbiesfailedDataStore = DataStore2("obbiesfailed",plr)
local completionrateDataStore = DataStore2("completionrate",plr)
local normalmodewinsDataStore = DataStore2("normalmodewins",plr)
local teammodewinsDataStore = DataStore2("teammodewins",plr)
local infectedmodewinsDataStore = DataStore2("infectedmodewins",plr)
local timeplayedDataStore = DataStore2("timeplayed",plr)
local bosswinsDataStore = DataStore2("bosswins",plr)
-- Main DataStore - Map Completion
local AnnihilatedWorldDataStore = DataStore2("AnnihilatedWorld",plr)
local BeeDataStore = DataStore2("Bee",plr)
local CharmingCreationDataStore = DataStore2("CharmingCreation",plr)
local CoralReefDataStore = DataStore2("CoralReef",plr)
local MysticCanyonDataStore = DataStore2("MysticCanyon",plr)
local PowerOutageDataStore = DataStore2("PowerOutage",plr)
local SkyFortressDataStore = DataStore2("SkyFortress",plr)
local TESTDataStore = DataStore2("TEST",plr)
local TempestArcanumDataStore = DataStore2("TempestArcanum",plr)
local TempleofMoonDataStore = DataStore2("TempleofMoon",plr)
-- Main DataStore - Value
local leaderstats = Instance.new("Folder",plr)
leaderstats.Name = "leaderstats"
local level = Instance.new("IntValue",leaderstats)
level.Name = "Level"
local xp = Instance.new("IntValue",leaderstats)
xp.Name = "XP"
local cash = Instance.new("IntValue",leaderstats)
cash.Name = "Cash"
local gold = Instance.new("IntValue",leaderstats)
gold.Name = "Gold"
local higheststreak = Instance.new("IntValue",leaderstats)
higheststreak.Name = "HighestStreak"
local questcompleted = Instance.new("IntValue",leaderstats)
questcompleted.Name = "QuestCompleted"
local obbiescompleted = Instance.new("IntValue",leaderstats)
obbiescompleted.Name = "ObbiesCompleted"
local obbiesfailed = Instance.new("IntValue",leaderstats)
obbiesfailed.Name = "ObbiesFailed"
local completionrate = Instance.new("IntValue",leaderstats)
completionrate.Name = "CompletionRate"
local normalmodewins = Instance.new("IntValue",leaderstats)
normalmodewins.Name = "NormalModeWins"
local teammodewins = Instance.new("IntValue",leaderstats)
teammodewins.Name = "TeamModeWins"
local infectedmodewins = Instance.new("IntValue",leaderstats)
infectedmodewins.Name = "InfectedModeWins"
local timeplayed = Instance.new("IntValue",leaderstats)
timeplayed.Name = "TimePlayed"
local bosswins = Instance.new("IntValue",leaderstats)
bosswins.Name = "BossWins"
-- Main DataStore - mapvalue
local mapstats = Instance.new("Folder",plr)
mapstats.Name = "mapstats"
local AnnihilatedWorld = Instance.new("IntValue",mapstats)
AnnihilatedWorld.Name = "AnnihilatedWorld"
local Bee = Instance.new("IntValue",mapstats)
Bee.Name = "Bee"
local CharmingCreation = Instance.new("IntValue",mapstats)
CharmingCreation.Name = "CharmingCreation"
local CoralReef = Instance.new("IntValue",mapstats)
CoralReef.Name = "CoralReef"
local MysticCanyon = Instance.new("IntValue",mapstats)
MysticCanyon.Name = "MysticCanyon"
local PowerOutage = Instance.new("IntValue",mapstats)
PowerOutage.Name = "PowerOutage"
local SkyFortress = Instance.new("IntValue",mapstats)
SkyFortress.Name = "SkyFortress"
local TEST = Instance.new("IntValue",mapstats)
TEST.Name = "TEST"
local TempestArcanum = Instance.new("IntValue",mapstats)
TempestArcanum.Name = "TempestArcanum"
local TempleofMoon = Instance.new("IntValue",mapstats)
TempleofMoon.Name = "TempleofMoon"
--
local function pointsUpdate(updatedValue)
level.Value = levelDataStore:Get(updatedValue)
xp.Value = xpDataStore:Get(updatedValue)
cash.Value = cashDataStore:Get(updatedValue)
gold.Value = goldDataStore:Get(updatedValue)
higheststreak.Value = higheststreakDataStore:Get(updatedValue)
questcompleted.Value = questcompletedDataStore:Get(updatedValue)
obbiescompleted.Value = obbiescompletedDataStore:Get(updatedValue)
obbiesfailed.Value = obbiesfailedDataStore:Get(updatedValue)
completionrate.Value = completionrateDataStore:Get(updatedValue)
normalmodewins.Value = normalmodewinsDataStore:Get(updatedValue)
teammodewins.Value = teammodewinsDataStore:Get(updatedValue)
infectedmodewins.Value = infectedmodewinsDataStore:Get(updatedValue)
timeplayed.Value = timeplayedDataStore:Get(updatedValue)
bosswins.Value = bosswinsDataStore:Get(updatedValue)
--
AnnihilatedWorld.Value = AnnihilatedWorldDataStore:Get(updatedValue)
Bee.Value = BeeDataStore:Get(updatedValue)
CharmingCreation.Value = CharmingCreationDataStore:Get(updatedValue)
CoralReef.Value = CoralReefDataStore:Get(updatedValue)
MysticCanyon.Value = MysticCanyonDataStore:Get(updatedValue)
PowerOutage.Value = PowerOutageDataStore:Get(updatedValue)
SkyFortress.Value = SkyFortressDataStore:Get(updatedValue)
TEST.Value = TESTDataStore:Get(updatedValue)
TempestArcanum.Value = TempestArcanumDataStore:Get(updatedValue)
TempleofMoon.Value = TempleofMoonDataStore:Get(updatedValue)
end
pointsUpdate(defaultValue)
--
levelDataStore:OnUpdate(pointsUpdate)
xpDataStore:OnUpdate(pointsUpdate)
cashDataStore:OnUpdate(pointsUpdate)
goldDataStore:OnUpdate(pointsUpdate)
higheststreakDataStore:OnUpdate(pointsUpdate)
questcompletedDataStore:OnUpdate(pointsUpdate)
obbiescompletedDataStore:OnUpdate(pointsUpdate)
obbiesfailedDataStore:OnUpdate(pointsUpdate)
completionrateDataStore:OnUpdate(pointsUpdate)
normalmodewinsDataStore:OnUpdate(pointsUpdate)
teammodewinsDataStore:OnUpdate(pointsUpdate)
infectedmodewinsDataStore:OnUpdate(pointsUpdate)
timeplayedDataStore:OnUpdate(pointsUpdate)
bosswinsDataStore:OnUpdate(pointsUpdate)
--
AnnihilatedWorldDataStore:OnUpdate(pointsUpdate)
BeeDataStore:OnUpdate(pointsUpdate)
CharmingCreationDataStore:OnUpdate(pointsUpdate)
CoralReefDataStore:OnUpdate(pointsUpdate)
MysticCanyonDataStore:OnUpdate(pointsUpdate)
PowerOutageDataStore:OnUpdate(pointsUpdate)
SkyFortressDataStore:OnUpdate(pointsUpdate)
TESTDataStore:OnUpdate(pointsUpdate)
TempestArcanumDataStore:OnUpdate(pointsUpdate)
TempleofMoonDataStore:OnUpdate(pointsUpdate)
end)