DataStore2 Saving with tables

so i have this script here, with a LOT of datastores, and i want to save them in a table instead of using like 2 million datastores

ive looked at the devforum for a bit and i still dont really understand soo

local DataStore2 = require(1936396537)
	
DataStore2.Combine("MasterKey", "Cash", "Net Worth", "Multiplier", "UltraMultiplier", "Autoclicker", "RobuxUpgrade", "RobuxUpgradeWorth", "JumpPower", "WalkSpeed", "Health", "Damage", "Rubies", "Sapphire", "Diamonds", "GBOM", "MultiBag", "UltraBag", "Sword")

local DefaultCash = 50
local DefaultNet = 50
local DefaultMulti = 1
local DefaultUltraMulti = 1
local DefaultRBXUpg = 1
local DefaultRBXUpgWorth = 15
local DefaultAuto = 1
local DefaultJump = 50
local DefaultWalk = 16
local DefaultHealth = 100
local DefaultDamage = 100
local DefaultRubies = 0
local DefaultSapphire = 0
local DefaultDiamonds = 0
local DefaultSword = false
local DefaultGBOM = false
local DefaultMultiBag = false
local DefaultUltraBag = false


game.Players.PlayerAdded:Connect(function(plr)
	print("Not Cloned")
	local Stats = script.PlayerData:Clone()
	print("Cloned")
	Stats.Parent = plr
	print("Stats")
	
	local Cash = DataStore2("Cash", plr)
	local Net = DataStore2("Net Worth", plr)
	local Multi = DataStore2("Multiplier", plr)
	local UltraMulti = DataStore2("UltraMultiplier", plr)
	local RBX = DataStore2("RobuxUpgrade", plr)
	local RBXW = DataStore2("RobuxUpgradeWorth", plr)
	local Auto = DataStore2("Autoclicker", plr)
	local Jump = DataStore2("JumpPower", plr)
	local Walk = DataStore2("WalkSpeed", plr)
	local Sword = DataStore2("Sword", plr)
	local Health = DataStore2("Health", plr)
	local Damage = DataStore2("Damage", plr)
	local Rubies = DataStore2("Rubies", plr)
	local Sapphire = DataStore2("Sapphire", plr)
	local Diamonds = DataStore2("Diamonds", plr)
	local GBOM = DataStore2("GBOM", plr)
	local MultiBag = DataStore2("MultiBag", plr)
	local UltraBag = DataStore2("UltraBag", plr)
	
	
	local function UpdateCash(cash)
		plr.PlayerData.Cash.Value = cash
	end
	
	local function UpdateNet(net)
		plr.PlayerData.Networth.Value = net
	end
	
	local function UpdateMulti(multi)
		plr.PlayerData.Multiplier.Value = multi
	end
	
	local function UpdateUltraMulti(umulti)
		plr.PlayerData.UltraMultiplier.Value = umulti
	end
	
	local function UpdateAuto(auto)
		plr.PlayerData.Autoclicker.Value = auto
	end
	
	local function UpdateRBX(rbx)
		plr.PlayerData.RobuxUpgrade.Value = rbx
	end
	
	local function UpdateRBXW(rbxw)
		plr.PlayerData.RobuxUpgradeWorth.Value = rbxw
	end
	
	local function UpdateJump(jump)
		plr.PlayerData.JumpPower.Value = jump
	end
	
	local function UpdateWalk(walk)
		plr.PlayerData.WalkSpeed.Value = walk
	end
	
	local function UpdateSword(sword)
		plr.PlayerData.Sword.Value = sword
	end
	
	local function UpdateHealth(health)
		plr.PlayerData.Health.Value = health
	end
	
	local function UpdateDamage(dmg)
		plr.PlayerData.Damage.Value = dmg
	end
	
	local function UpdateRubies(rubies)
		plr.PlayerData.Rubies.Value = rubies
	end
	
	local function UpdateSapphire(sapphire)
		plr.PlayerData.Sapphire.Value = sapphire
	end
	
	local function UpdateDiamonds(diamonds)
		plr.PlayerData.Diamonds.Value = diamonds
	end
	
	local function UpdateGBOM(gbom)
		plr.PlayerData.GBOM.Value = gbom
	end
	
	local function UpdateMultiBag(mbag)
		plr.PlayerData.MultiBag.Value = mbag
	end
	
	local function UpdateUltraBag(ubag)
		plr.PlayerData.UltraBag.Value = ubag
	end

	
	UpdateCash(Cash:Get(DefaultCash))
	UpdateNet(Net:Get(DefaultNet))
	UpdateMulti(Multi:Get(DefaultMulti))
	UpdateUltraMulti(UltraMulti:Get(DefaultUltraMulti))
	UpdateRBX(RBX:Get(DefaultRBXUpg))
	UpdateRBXW(RBXW:Get(DefaultRBXUpgWorth))
	UpdateAuto(Auto:Get(DefaultAuto))
	UpdateJump(Jump:Get(DefaultJump))
	UpdateWalk(Walk:Get(DefaultWalk))
	UpdateSword(Sword:Get(DefaultSword))
	UpdateHealth(Health:Get(DefaultHealth))
	UpdateDamage(Damage:Get(DefaultDamage))
	UpdateRubies(Rubies:Get(DefaultRubies))
	UpdateSapphire(Sapphire:Get(DefaultSapphire))
	UpdateDiamonds(Diamonds:Get(DefaultDiamonds))
	UpdateGBOM(GBOM:Get(DefaultGBOM))
	UpdateMultiBag(MultiBag:Get(DefaultMultiBag))
	UpdateUltraBag(UltraBag:Get(DefaultUltraBag))
	
	
	Cash:OnUpdate(UpdateCash)
	Net:OnUpdate(UpdateNet)
	Multi:OnUpdate(UpdateMulti)
	UltraMulti:OnUpdate(UpdateUltraMulti)
	RBX:OnUpdate(UpdateRBX)
	RBXW:OnUpdate(UpdateRBXW)
	Auto:OnUpdate(UpdateAuto)
	Jump:OnUpdate(UpdateJump)
	Walk:OnUpdate(UpdateWalk)
	Sword:OnUpdate(UpdateSword)
	Health:OnUpdate(UpdateHealth)
	Damage:OnUpdate(UpdateDamage)
	Rubies:OnUpdate(UpdateRubies)
	Damage:OnUpdate(UpdateDamage)
	Rubies:OnUpdate(UpdateRubies)
	Sapphire:OnUpdate(UpdateSapphire)
	Diamonds:OnUpdate(UpdateDiamonds)
	GBOM:OnUpdate(UpdateGBOM)
	MultiBag:OnUpdate(UpdateMultiBag)
	UltraBag:OnUpdate(UpdateUltraBag) 
end)

dont cringe

You can save tables in DataStore2 just like normal DataStore’s, an example would be:

local DataStore2 = require(1936396537)
DataStore2.Combine("DATA", "DATA")
local DataStore = DataStore2("DATA", playerInstance)
DataStore:Set({
   [1] = "something",
   [2] = "something else"
}) -- to save it

DataStore:Get({}) -- to get it
1 Like

ohhh interesting thank you i will try it out