How to delete everything in the datastore?

It’s okay, @Wizzthepixelcat! At least you tried to help me, and I really appreciate it. You can test it on your own and see what I mean, because I could probably not explain it very well.

1 Like

Cant you just change the name of the datastore instead

I have already deleted the datastore of my server script, which is why I am so confused. To be honest, I forgot how it was.

I think problem is with your data save, because when you delete data and rejoin you still have data but it’s still deleting it

I know it’s a bit confusing, but yes. Note that I am disabling all server scripts and local scripts and then running the datastore deleter server script.

Try making new variable called “DataExists” and make it saves after player joins and leaves, and insert in loop that if DataExists == false then delete data and if else just return

Like this?

wait(3)
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 DataExists == false then
                    print("Deleting " .. Key.KeyName .. "...")
                    DataStore:RemoveAsync(Key.KeyName)
                else
                    return
                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")

Note that I didn’t make this server script on Studio but here, so I don’t know if it has any errors.

1 Like

Did you make “DataExists” part of Data? Because that’s what you had to do

No, I didn’t, but I just found the “main” datastore. It called “AllFramesDataStore”. Inside this, there is everything that gets printed, but I want to delete “AllFramesDataStore”.

Can you show me?
Maybe I can solve that

Unfortunately, I can’t send you the full code, but I will send you some parts of it.

local DataStoreService = game:GetService("DataStoreService")
local AllFramesDataStore = DataStoreService:GetDataStore("AllFramesDataStore")
local savedFramesData = AllFramesDataStore:GetAsync("AllFramesData") or {}
AllFramesDataStore:SetAsync("AllFramesData", savedFramesData)

-- Yes, that's the only thing I can provide. It's still something, at least.

Hmm… Well, I can’t help with that sorry, Hope I helped you with small things to solve small problems

Understood. I am sorry for not being able to send you the full code. Thank you so much for your time and for all your help!

1 Like

You can message me anytime if you got any problems to solve

Oh really? Thank you! :happy1:
Don’t worry, I will, but probably not now but in the future.

1 Like

Simply changing the name of the Datastore would create a new empty one if thats what u want, let me know if u need help deleting the data in the previous datastore permanently.

local AllFramesDataStore = DataStoreService:GetDataStore("AllFramesDataStore_2")

Hello @teodormihai1! Yes, I would like to know how to delete all the data in my previous datastore permanently without creating a new one.

Running this code in the studio command bar should do it, note that this will wipe all data in the datastore empty, let me know if u wanna do this within a script instead of the command bar

local DataStoreService = game:GetService("DataStoreService")
local AllFramesDataStore = DataStoreService:GetDataStore("AllFramesDataStore")
AllFramesDataStore:RemoveAsync("AllFramesData")

If I understood you well, you told me to run this code:

On the command bar. I did it, and when I joined the game, the server script that deletes the data was still deleting data.
image
image

To be honest, the latest data store was AllFramesDataStore, but it could be more data stores than AllFramesDataStore.