I have a datastore that loads up 7007 different entries for a Canvas. It can take up to 10-20 minutes to load it up fully, and I want to know how to speed it up.
script;
local datastore = game:GetService("DataStoreService")
local DS2 = datastore:GetDataStore("TilesNewer")
--local va =datastore:GetDataStore("Tiles")
local asv = workspace.Baseplate.Canvas:getChildren()
local numb = 0
local finishedloading = false
local loadingmsg = Instance.new("Message",workspace)
loadingmsg.Text = "Loading up the Canvas, It will take up to several minutes."
game.Lighting.allslots.Value = #asv - 1
loadingupslot = false
for i=1, #asv do
if asv[i]:IsA("ImageButton") then
--repeat wait() until loadingupslot == false
--print(numb)
--table.insert(stupidpeople,asv[i])
--va:SetAsync(tostring(asv[i].Name),{1,1,1})
task.spawn(function()
numb = numb + 1
game.Lighting.slotsloaded.Value = numb
if numb == (#asv - 1) then
--loadingmsg:Destroy()
loadingmsg:Destroy()
finishedloading = true
game.Lighting.Loading.Value = false
local loadingmsgv = Instance.new("Message",workspace)
loadingmsgv.Text = "Done! You can now start painting!"
game.Debris:AddItem(loadingmsgv,2)
end
end)
local ready = false
task.spawn(function()
local data
local success, response = pcall(function()
data = DS2:GetAsync(tostring(asv[i].Name))
end)
if success then
ready = true
if data ~= nil then
--print(data[1])
--print(data[2])
--print(data[3])
asv[i].BackgroundColor3 = Color3.new(data[1],data[2],data[3])
asv[i].ImageColor3 = Color3.new(data[1],data[2],data[3])
end
else
ready = true
--DS2:SetAsync(tostring(asv[i].Name),{1,1,1})
end
end)
repeat wait() until ready == true
--print("Slot "..asv[i].Name.." has loaded.")
end
end
--for i=1,#stupidpeople do
-- local data = va:GetAsync(tostring(stupidpeople[i].Name))
-- if data then
-- local vars = workspace.Baseplate.Canvas:FindFirstChild(stupidpeople[i].Name)
-- if vars ~= nil then
-- if data ~= nil then
-- vars.BackgroundColor3 = Color3.new(data[1],data[2],data[3])
-- end
-- end
-- end
--end