DataStore with Table

Hello! I tryed to make a table data store with print().
but the Output show me a error…

image

here script:

local datastore = game:GetService("DataStoreService")
local mydata = datastore:GetDataStore("mydata")

local success, err = pcall(function()
	mydata:SetAsync("list", "text1")
	mydata:SetAsync("list", "text2")
end)
if success then
	print("success!")
else
	error("error: "..err)
end

local dataTable = mydata:GetAsync("list")

for i, v in pairs(dataTable) do
	print(i,v)
end

I enabled the API Service.
thank you in advance!

1 Like

At the moment you’re attempting to loop through dataTable When you have stored a string value which is "text2"

a table is usually multiple values within curly brackets {}

I think you were going for

local success, err = pcall(function()
	mydata:SetAsync("list", {"text1","text2"})
end)
1 Like

wow thank you very much!

image

it worked thank!

1 Like