local DataStoreService = game:GetService("DataStoreService")
local listSuccess, pages = pcall(function()
return DataStoreService:ListDataStoresAsync("PlayerStats_TestTwo")
end)
if listSuccess then
while true do
local data = pages:GetCurrentPage()
for rank,stuff in pairs(data) do
Player = Instance.new("StringValue")
Player.Parent = game.Workspace.Players
print(stuff.Value)
end
if pages.IsFinished then
break
end
data:AdvanceToNextPageAsync()
end
end
The print function breaks, All I know is that “stuff” is a Page Instance but I don’t know how to get the value out of it
Please help I cant find anything anywhere about this
EDIT: “PlayerStats_TestTwo” is PlayerID as the Key and a string as the Value but i cant get either of them from “stuff”
local DataStoreService = game:GetService("DataStoreService")
local players = workspace:WaitForChild("Players")
local pages
local succ, err = pcall(function()
pages = DataStoreService:ListDataStoresAsync("PlayerStats_TestTwo")
end)
if succ then
while task.wait() do
local data = pages:GetCurrentPage()
for index, value in pairs(data) do
Player = Instance.new("StringValue")
Player.Parent = players
end
if pages.IsFinished then
break
end
data:AdvanceToNextPageAsync()
end
end
The while true do might’ve caused a crash so I’ve added a yielding function call, also are you sure you want to create StringValue instances that frequently? You may also want to customise them.
local DataStoreService = game:GetService("DataStoreService")
local players = workspace:WaitForChild("Players")
local pages
local succ, err = pcall(function()
pages = DataStoreService:ListDataStoresAsync("PlayerStats_TestTwo")
end)
if succ then
while task.wait() do
local data = pages:GetCurrentPage()
for index, value in pairs(data) do
Player = Instance.new("StringValue")
Player.Parent = players
end
if pages.IsFinished then
break
end
data:AdvanceToNextPageAsync()
end
end
Please read documentation, you don’t. ListDataStoresAsync is only intended to list DataStores with data in them. It returns a DataStoreListingPages with DataStoreInfo instances. DataStoreInfo, as it says on the tin, only provides information about a DataStore. Values aren’t associated with DataStores.
It seems like you were looking for ListKeysAsync though the above still applies here as well; it returns a DataStoreKeyPages with DataStoreKey instances. It does not provide the value of the key.
If you want the value of a key, you need to use GetAsync.