How to delete everything in the datastore?

You are correct! :cool:

Glad I could help you :smile: feel free to mention me btw.

By the way, @teodormihai1. Which server script should I use?
Datastore Deleter 1:

local DSS = game:GetService("DataStoreService")

local DataStorePages = DSS:ListDataStoresAsync()

while true do

	local CurrentStoresPage = DataStorePages:GetCurrentPage()

	for i, DataStoreInfo in pairs(CurrentStoresPage) do

		local DataStore = DSS:GetDataStore(DataStoreInfo.DataStoreName)

		local KeysPages = DataStore:ListKeysAsync()

		while true do

			local CurrentKeysPage = KeysPages:GetCurrentPage()

			for j, Key in pairs(CurrentKeysPage) do

				local KeyStore = DataStore:GetAsync(Key.KeyName)

				if KeyStore ~= nil then

					if string.len(tostring(KeyStore)) >= 1 then

						print(tostring(KeyStore))
                        print("Deleting: " .. Key.KeyName)


						DataStore:SetAsync(Key.KeyName, "")
					end
				end
			end

			if KeysPages.IsFinished then
				break
			end

			KeysPages:AdvanceToNextPageAsync()
		end
	end

	if DataStorePages.IsFinished then
		break
	end

	DataStorePages:AdvanceToNextPageAsync()

	task.wait()
end

print("Done Deleting Data")

Datastore Deleter 2:

-- Made by: Bikereh (1245828306)

-- Wait for 3 seconds before starting execution
wait(3)
-- Get a reference to the DataStoreService
local DSS = game:GetService("DataStoreService")
-- Retrieve a list of all available DataStores asynchronously
local DataStorePages = DSS:ListDataStoresAsync()
-- Continuously loop through each page of DataStores
while true do
    -- Get the current page of DataStores
	local CurrentStoresPage = DataStorePages:GetCurrentPage()
	-- Iterate through each DataStore in the current page
	for i, DataStoreInfo in pairs(CurrentStoresPage) do
		-- Get a reference to the current DataStore
		local DataStore = DSS:GetDataStore(DataStoreInfo.DataStoreName)
		-- Retrieve a list of keys in the current DataStore asynchronously
		local KeysPages = DataStore:ListKeysAsync()
		-- Continuously loop through each page of keys in the DataStore
		while true do
			-- Get the current page of keys
			local CurrentKeysPage = KeysPages:GetCurrentPage()
			-- Iterate through each key in the current page
			for j, Key in pairs(CurrentKeysPage) do
				-- Retrieve the value associated with the current key
				local KeyStore = DataStore:GetAsync(Key.KeyName)
				-- Print a message indicating that the key is being deleted
				print("Deleting: " .. Key.KeyName)
				-- Remove the key from the DataStore
				DataStore:RemoveAsync(Key.KeyName)
			end
			-- Exit the inner loop if all keys have been processed
			if KeysPages.IsFinished then
				break
			end
			-- Move to the next page of keys asynchronously
			KeysPages:AdvanceToNextPageAsync()
		end
	end
	-- Exit the outer loop if all DataStores have been processed
	if DataStorePages.IsFinished then
		break
	end
	-- Move to the next page of DataStores asynchronously
	DataStorePages:AdvanceToNextPageAsync()
	-- Wait for a short period before continuing the loop
	task.wait()
end
-- Print a message indicating that data deletion is complete
print("Done deleting data")

Don’t worry, I will mention you in my future posts. I saved your user ID. :cool:

The original one was actually pretty not smart cause if u do :GetDataStore(“whatever”) once in a script its always gonna show even if it has data or not flooding the output especially if u have a big game that has tons of data, mine only shows existing data so i advise you use it

Don’t worry I will use it! :happy1:
I also gave credit at the top of the script, so I will remember that you helped me. :wink:

Glad I could help! Have a great day! :wave:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.