Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to test if a datastore exists?

I'm making a (weird) save, please don't say that I should make another kind of save because I want to do it this way xD. so the question, how do I detect if a datastore exists? I have no script pieces because that's the first thing I need to know so I have to start with that, I don't need a prebuilt script, just a wiki link or some explanation...

1 answer

For all intents and purposes, as soon as you get a reference to a DataStore

local myDataStore= game:GetService('DataStoreService'):GetDataStore('MyData')

you can think of it as "existing".

The only thing you can really do is check is whether or not any data has previously been written to it.

local value = myDataStore:GetAsync('key')
if value == nil then
    print("A value does not exist in 'myDataStore' for key 'key'")
end

This discussion is preserved as it was. New answers, comments, and votes are closed.