Hello developers, I’m trying to load all of the player data into a game and it works but it takes exessive amounts of time to load them in due to the request queue filling up.
I’ve tried looking for other responses on the DevForum but I couldn’t find anything that I knew how to do.
This script uses the DataStore2 Module made by Kampfkarren.
Data Script
local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
local Workspace = game:GetService("Workspace")
local DataStore2 = require(ServerScriptService.DataStore2)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
swordTable = {}
for i,v in ipairs(require(game:GetService("ReplicatedStorage"):WaitForChild("Modules"):WaitForChild("CrateModules")).GetItemTypes()) do
for i,v in pairs(v.Items) do
table.insert(swordTable, tostring(v.Name))
end
end
DataStore2.Combine(
"DATA",
"Time",
"Top",
"Kills",
"EQ",
"Tweens",
"TimeLight",
table.unpack(swordTable),
"TournamentWins",
"TournamentBool"
)
Players.PlayerAdded:Connect(function(player)
task.wait(10) -- for dif script to be able to load with this
local timeStore = DataStore2("Time", player)
local topStore= DataStore2("Top", player)
local koStore = DataStore2("Kills", player)
local eqStore = DataStore2("EQ", player)
local TweensStore = DataStore2("Tweens", player)
local TimeLightStore = DataStore2("TimeLight", player)
local InventoryStore = DataStore2("Inventory", player)
local TournamentWinsStore = DataStore2("TournamentWins", player)
local TournamentBoolStore = DataStore2("TournamentBool", player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
--
local inv = Instance.new("Folder")
inv.Name = "Inventory"
--
local otherstats = Instance.new("Folder")
otherstats.Name = "OtherStats"
--
local settingfolder = Instance.new("Folder")
settingfolder.Name = "Settings"
--
local Time = Instance.new("NumberValue")
Time.Name = "Time"
Time.Value = timeStore:Get(0)
Time.Parent = leaderstats
--
local Top = Instance.new("NumberValue")
Top.Name = "Top"
Top.Value = topStore:Get(0)
Top.Parent = leaderstats
--
local KO = Instance.new("NumberValue")
KO.Name = "Kills"
KO.Value = koStore:Get(0)
KO.Parent = leaderstats
local EQ = Instance.new("StringValue")
EQ.Name = "EQ"
EQ.Value = eqStore:Get("Classic")
EQ.Parent = otherstats
local Tweens = Instance.new("BoolValue")
Tweens.Name = "Tweens"
Tweens.Value = TweensStore:Get(true)
Tweens.Parent = settingfolder
local TimeLight = Instance.new("StringValue")
TimeLight.Name = "TimeLight"
TimeLight.Value = TimeLightStore:Get("Day")
TimeLight.Parent = settingfolder
local TournamentWins = Instance.new("NumberValue")
TournamentWins.Name = "TournamentWins"
TournamentWins.Value = TournamentWinsStore:Get(0)
TournamentWins.Parent = otherstats
local TournamentBool = Instance.new("BoolValue")
TournamentBool.Name = "TournamentBool"
TournamentBool.Value = TournamentBoolStore:Get(false)
TournamentBool.Parent = otherstats
timeStore:OnUpdate(function(newPoints)
Time.Value = newPoints
end)
--
topStore:OnUpdate(function(newPoints)
Top.Value = newPoints
end)
--
koStore:OnUpdate(function(newPoints)
KO.Value = newPoints
end)
eqStore:OnUpdate(function(newPoints)
EQ.Value = newPoints
end)
TweensStore:OnUpdate(function(newPoints)
Tweens.Value = newPoints
end)
TimeLightStore:OnUpdate(function(newPoints)
TimeLight.Value = newPoints
end)
TournamentWinsStore:OnUpdate(function(newPoints)
TournamentWins.Value = newPoints
end)
TournamentBoolStore:OnUpdate(function(newPoints)
TournamentBool.Value = newPoints
end)
--
leaderstats.Parent = player
inv.Parent = player
settingfolder.Parent = player
otherstats.Parent = player
for i,v in ipairs(require(game:GetService("ReplicatedStorage"):WaitForChild("Modules"):WaitForChild("CrateModules")).GetItemTypes()) do
for i,v in pairs(v.Items) do
DataStore2(v.Name, player):Get(0)
local inst = Instance.new("NumberValue")
inst.Name = v.Name
inst.Parent = inv
inst.Value = DataStore2(v.Name, player):Get()
DataStore2(v.Name, player):OnUpdate(function(newPoints)
inst.Value = newPoints
end)
end
end
end)
If you’re able to give me some suggestions on how to fix this / mitigate the overfilled queue please do so! It will be greatly appreciated.