How can I reset a datastore?

So I have a datastore which I want admins to have a reset button for which resets the whole datastore. How would I make it so the data in the datastore is all deleted?

14 Likes

You need to make a new datastore, you can’t clear out any data

Please search for things before making posts, this was already answered here: Is there anyway to clear out all data in a datastore? - #2 by PeZsmistic

7 Likes

I just know that if you change the name of the datastore, you change the entire datastore. For example, if you change DataStore to DataStore2 you will have completely different datastores.

4 Likes

You Don’t
If you’re generating the keys based such as "user_" .. Player.UserId , then resetting all player data is simple as changing user_ to something else.

This is an unfortunate limitation in how Roblox handles datastores, however there is not a better way to manage this as Roblox only exposes an in-game API and expects persistence for the foreseeable future; They also expect you to use a testing database for testing, or to not enable Studio API access.

5 Likes

To clear confusion, it was because he was asking if he could delete data already saved inside of a datastore which is impossible.

As to your other question that would be another solution that was also mentioned in the post I linked above.

1 Like

I don’t think that there is a way to clear data. The only thing you can do is changing the datastore name which will result in a total data reset of all players.

5 Likes

Isn’t remove:Async a way to remove data?

13 Likes

For those still wondering 3 years later, you can use this simple loop to wipe all keys from the datastore.

local pages: DataStoreKeyPages = exampleDataStore:ListKeysAsync()
while true do
	local keys: {DataStoreKey} = pages:GetCurrentPage()
	for _, key in ipairs(keys) do
		exampleDataStore:RemoveAsync(key.KeyName)
	end
	if pages.IsFinished then break end
	pages:AdvanceToNextPageAsync()
end
6 Likes

You really just can’t, you have to create a new datastore if you want to reset it

sorry, but you can’t, u need to create a new one :sad: