How do I make a datastore with more than 1 value?

I’ve been learning how to create a datastore script but the problem is that I didn’t find information on how to make one with more than 2 values and I didn’t succeed in making one.

The script I made (ignore the two lines related to a remote event):

local DataStoreService = game:GetService(“DataStoreService”)
local Teststorage = DataStoreService:GetDataStore(“TestCoin1”)

game.Players.PlayerAdded:Connect(function(player)
local data
local success, erro = pcall(function()
data = Teststorage:GetAsync(player.UserId…“TestCoin1”)
end)
if success then
player.DataStore.TestCoin1.Value = data
local p = “recuperado”
game.ReplicatedStorage.Events.Assets.DataStore:FireClient(player , p)
else
print(“dont work”)
warn(erro)
end
end)

game.Players.PlayerRemoving:Connect(function(player)
local sucess,erro = pcall(function()
Teststorage:SetAsync(player.UserId…“TestCoin1”,player.DataStore.TestCoin1.Value)
end)

if sucess then
	print("saved")
else
	print("dont saved")
	warn(erro)
end

end)

I couldn’t put the value “TestCoin2” inside the script so is there a way to put “TestCoin2” inside the script?

1 Like

I am not a hundred percent sure what you are asking but I think the answer you need is that you can save arrays or tables. With saving tables you should also check out ’ Iterating Over Arrays’ and ’ Iterating Over Dictionaries’ sections of the article.

1 Like

Now that I remember it must be this, I will study this so thanks.