[DataStore2] - Save string in array with DataStore2

  1. What do you want to achieve? Save a string in an array with DataStore2 module.

  2. What is the issue? It doesn’t save the StringValue name when I test studio again. (SaveInStudio is Enabled)

  3. What solutions have you tried so far? There’s no solutions for this so far.

	local CashDataStore = PlayerDataModule.DataStore2("Cash", Player)
	local TokensDataStore = PlayerDataModule.DataStore2("Tokens", Player)
	local TowerDataStore = PlayerDataModule.DataStore2("TowerDataStore", Player)
	TowerDataStore:Set(DataStoreTable)

	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = Player
	
	local TowerData = Instance.new("Folder")
	TowerData.Name = Player.Name.."'s TowerPurchaseData"
	TowerData.Parent = PlayerDataModule.ServerScriptService

	local Cash = Instance.new("IntValue")
	Cash.Name = "Cash"
	Cash.Parent = leaderstats

	local Tokens = Instance.new("IntValue")
	Tokens.Name = "Tokens"
	Tokens.Parent = leaderstats
	
	coroutine.resume(coroutine.create(function()
		while true do
			for i, v in ipairs(DataStoreTable) do
				print(v)
			end
			task.wait(3)
		end
	end))
	
	TowerData.ChildAdded:Connect(function(TowerString)
		table.insert(DataStoreTable, TowerString.Name)
		for i, v in ipairs(DataStoreTable) do
			print(v.." was added to DataStoreTable! (Array)")
		end
	end)
	
	local function UpdateCash(Cash_Amount)
		Cash.Value = CashDataStore:Get(Cash_Amount)
	end

	local function UpdateTokens(Tokens_Amount)
		Tokens.Value = TokensDataStore:Get(Tokens_Amount)
	end

	coroutine.wrap(function()
		UpdateCash(CashAmount) UpdateTokens(TokensAmount)
		CashDataStore:OnUpdate(UpdateCash) TokensDataStore:OnUpdate(UpdateTokens)
	end)()

I do not an entire script of an solution I want an code block example. Please do not include an entire script of an solution.

Am I doing something wrong with this code?

Any replies on this topic either a solution or an suggestion will be greatly appreciated.