Delete Any or All DataStores, [ Works With Tables ]

7You Can Now Easily Delete Any Or All DataStores. Just Insert This Script Into Any Script And Run!

Could still use little improvement for overloading and performance but does what it’s supposed to do.

For Deleting One DataStore:

local DataStoreService = game:GetService("DataStoreService")

-- Insert DataStore Name Here vvv
local DataStoreName = "TestDataStore"


local DataStore = DataStoreService:GetDataStore(DataStoreName)

local Success, Pages = pcall(function()
	return DataStore:ListKeysAsync()
end)

if not Success then warn("Timeout") return end

while task.wait() do
	
	local Items = Pages:GetCurrentPage()
	
	for _, Data in ipairs(Items) do
		
		-- Deletes Data:
		local Key = Data.KeyName
		
		DataStore:RemoveAsync(Key)
		
		task.wait(3)
		
	end
	
	if Pages.IsFinished then break else Pages:AdvanceToNextPageAsync() end
	
end

For Deleting All DataStores:

local DataStoreService = game:GetService("DataStoreService")

local Success, DataStorePages = pcall(function()
	return DataStoreService:ListDataStoresAsync()
end)
if not Success then return end


-- Gets Data Store Names:

local DataStoreNames = {}
while task.wait() do
	
	local DataStorePage = DataStorePages:GetCurrentPage()
	
	for _, DataStore in pairs(DataStorePage) do
		table.insert(DataStoreNames, DataStore.DataStoreName)
	end
	
	if DataStorePages.IsFinished then break else DataStorePages:AdvanceToNextPageAsync() end
	
end

-- Gets Data Of DataStores:

for _, DataStoreName in ipairs(DataStoreNames) do
	
	local DataStore = DataStoreService:GetDataStore(DataStoreName)
	
	local Success, Pages = pcall(function()
		return DataStore:ListKeysAsync()
	end)
	
	if not Success then warn("Timeout") continue end
	
	while task.wait() do
		
		local Items = Pages:GetCurrentPage()
		
		for _, Data in ipairs(Items) do
			
			-- Deletes Data:
			local Key = Data.KeyName
			
			DataStore:RemoveAsync(Key)
			
			task.wait(3)
			
		end
		
		if Pages.IsFinished then break else Pages:AdvanceToNextPageAsync() end
		
	end
	
end

Bruh :cold_face:

8 Likes

How can I do this for DataStores (DataStore2) with a LOT of data?

I just get this error, no matter how long of a wait I put:
502: API Services rejected request with error. HTTP 429

and I get a bunch of these yellow warnings, like:
Error getting name for _______. Error: Players.GetNameFromUserIdAsync() failed: HTTP 429

DataStore2 isn’t as easy to delete because it has a lot of backups, but if you are interested then here is a method to delete one single users data:

As for all data, you can try adding yields to help prevent HTTP 429 Errors (which means you are being ratelimited), although it could take a long time depending on how much data you have.

2 Likes