Hello. I am trying to delete all the data stores in my game. I no longer use them and I am recieving floods of messages about right to erasure.
What is the best technique to rid all of the data store?
1 Like
local DataStoreService = game:GetService("DataStoreService")
local DataStorePages = DataStoreService:ListDataStoresAsync()
while true do
local CurrentStoresPage = DataStorePages:GetCurrentPage()
for i, DataStoreInfo in pairs(CurrentStoresPage) do
local DataStore = DataStoreService:GetDataStore(DataStoreInfo.DataStoreName)
local KeysPages = DataStore:ListKeysAsync()
while true do
local CurrentKeysPage = KeysPages:GetCurrentPage()
for i, key in pairs(CurrentKeysPage) do
local success, keystore = pcall(function()
return DataStore:GetAsync(key.KeyName)
end)
if success and keystore then
DataStore:RemoveAsync(key.KeyName)
end
end
if KeysPages.IsFinished then
break
else
KeysPages:AdvanceToNextPageAsync()
end
end
end
if DataStorePages.IsFinished then
break
else
DataStorePages:AdvanceToNextPageAsync()
end
task.wait()
end
5 Likes
local function resetDataStores()
local dataStoreService = game:GetService"DataStoreService"
local listDataStores = dataStoreService.ListDataStoresAsync
local success, result = pcall(listDataStores, dataStoreService)
if success then
if result then
local advanceToNextListingPage = result.AdvanceToNextPageAsync
local dataStoreListingPage = result:GetCurrentPage()
repeat
for _, dataStoreListing in ipairs(dataStoreListingPage) do
local dataStore = dataStoreService:GetDataStore(dataStoreListing.DataStoreName)
local orderedDataStore = dataStoreService:GetOrderedDataStore(dataStoreListing.DataStoreName)
if dataStore then
local listKeys = dataStore.ListKeysAsync
local remove = dataStore.RemoveAsync
local success2, result2 = pcall(listKeys, dataStore)
if success2 then
if result2 then
local advanceToNextKeyPage = result2.AdvanceToNextPageAsync
local dataStoreKeyPage = result2:GetCurrentPage()
repeat
for _, dataStoreKey in ipairs(dataStoreKeyPage) do
local success3, result3 = pcall(remove, dataStore, dataStoreKey.KeyName)
if success3 then
if result3 then
continue
end
else
warn(result3)
end
end
if not result2.IsFinished then
local success4, result4 = pcall(advanceToNextKeyPage, result2)
if success4 then
if result4 then
do end
end
else
warn(result4)
end
end
until result2.IsFinished
end
else
warn(result2)
end
end
if orderedDataStore then
local listKeys = orderedDataStore.ListKeysAsync
local remove = orderedDataStore.RemoveAsync
local success5, result5 = pcall(listKeys, orderedDataStore)
if success5 then
if result5 then
local advanceToNextKeyPage = result5.AdvanceToNextPageAsync
local dataStoreKeyPage = result5:GetCurrentPage()
repeat
for _, dataStoreKey in ipairs(dataStoreKeyPage) do
local success6, result6 = pcall(remove, orderedDataStore, dataStoreKey.KeyName)
if success6 then
if result6 then
continue
end
else
warn(result6)
end
end
if not result5.IsFinished then
local success7, result7 = pcall(advanceToNextKeyPage, result5)
if success7 then
if result7 then
do end
end
else
warn(result7)
end
end
until result5.IsFinished
end
else
warn(result5)
end
end
end
if not result.IsFinished then
local success8, result8 = pcall(advanceToNextListingPage, result)
if success8 then
if result8 then
do end
end
else
warn(result8)
end
end
until result.IsFinished
end
else
warn(result)
end
end
resetDataStores()
An implementation for both DataStores & OrderedDataStores.
1 Like
Unfortunately both solutions fail as this issue crops up.
"DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = 1233602117 - "