Hey guys! I would like my Level save data to be put into a table as I'll have like 20-25 levels. Now the there is 3 save data. 1 and 2 should be ignored now. save data 3 is the one responsible for saving LevelOne's data. and I would like to make save data 3 a table to be able to save many level's boolvalue. Could you please help? I looked it up and I don't understand how can I make a table out of save datas. Thank you so much!
local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("CompleteSaveSystem")
local ds2 = datastore:GetDataStore("TTSaveSystem")
local ds3 = datastore:GetDataStore("LevelTrack")
game.Players.PlayerAdded:connect(function(plr)
local folder = Instance.new("Folder", plr)
folder.Name = "leaderstats"
local Complete = Instance.new("IntValue", folder)
Complete.Name = "Completes"
local TT = Instance.new("IntValue", folder)
TT.Name = "Tree Tokens"
local folder2 = Instance.new("Folder", plr)
folder2.Name = "LevelTracking"
local LevelOne = Instance.new("BoolValue", folder2)
LevelOne.Name = "LevelOne"
Complete.Value = ds1:GetAsync(plr.UserId) or 0
ds1:SetAsync(plr.UserId, Complete.Value)
TT.Value = ds2:GetAsync(plr.UserId) or 0
ds2:SetAsync(plr.UserId, TT.Value)
LevelOne.Value = ds3:GetAsync(plr.UserId)
ds3:SetAsync(plr.UserId, LevelOne.Value)
Complete.Changed:connect(function()
ds1:SetAsync(plr.UserId, Complete.Value)
end)
TT.Changed:connect(function()
ds2:SetAsync(plr.UserId, TT.Value)
end)
LevelOne.Changed:connect(function()
ds3:SetAsync(plr.UserId, LevelOne.Value)
end)
end)

12 comments
I don't quite understand your question, are you asking how to save data in a datastore as a table?
Yes
First of all you should only store data when you're leaving the game as if you're storing it whenever it changes, and if it changes a lot it will error because there are too many storing updates.
It changes a very few times, but could you help me with what Ive asked please?
So you'd like to save 1 boolean in the table?
Right now yes, later 20-25
You need to elaborate on your question I don't understand what you mean by "many level's boolvalue"
LevelOne is a bool value. I would like to have LevelTwo LevelThree and so on.
Why would you do that?
Its a system thar saves if you comeplted a level. Dont mind that
Well you could just store your completed levels in a table instead of having an individual value for all of them
For example: levelsCompleted = {} function levelCompleted(level) table.insert(levelsCompleted, #levelCompleted + 1, level) end levelCompleted(1)