Hi, I'm making a game where you attack other players' bases. Kind of like in Clash Of Clans. The problem is that my script for loading the bases is somehow too slow. Here is the "main part" of the script
local dsb = game:GetService("DataStoreService"):GetDataStore("Buildingsalpha") local folder = Instance.new("Folder") folder.Parent = workspace folder.Name = "buildings" for i = 1, #workspace.BuildingRaster:GetChildren() do local raster = workspace.BuildingRaster local buildings = dsb:GetAsync(players[player]) if buildings[i] ~= "LEER" then local gebaude = game.Lighting[buildings[i]]:Clone() gebaude.Parent = workspace.buildings gebaude:MoveTo(raster[i].Position) end end
"players [player]" is the id of the random base player. It is probably running slowly because of the datastore instead of everything running immediately. Is it possible to save datastore information in variables or something so that the script does not always have to query the datastore? The datastore info is a table, for information only. I look forward to answering.
Didn't you answer your own question? Use variables. Make value instances for all the info then save to them and load from them so it's fast.bita how most inventory systems work, it takes too long to get foem datastores all the time and set them. Just set the datastores to the value of the value instances when the player is leaving and/or a manual save, always useful.
I hope this helps :3