GetDataStore errors when not in Edit mode

Previously, you could call GetDataStore no matter what, Edit mode or not, and only when you attempted Get/Set/UpdateAsync could you get an error. Naturally, I always wrap the latter three in pcall()s–but not GetDataStore.

Now GetDataStore is throwing the error, so I am having to pcall-wrap those calls just to test my game in Play Solo (it’s the same error: “Place has to be opened with Edit button to access DataStores”). It’s kind of annoying so please fix :slight_smile:

1 Like

From what I recall, this has always errored if the place isn’t published.

It hasn’t because I have used it this way for years and only today had to rewrite my code.

I’ve had pcalls for mine for a long time, I’m almost positive it has always errored.

Are you sure your place is published?

No; in fact I’m sure that my place is NOT published. I do not publish each time I edit. I have to publish in waves, because each update is more than a day’s worth of work. I open the place from disk and save to disk.

The issue is not that I can’t access DataStore API. I know good and well that I can’t. I don’t want to.

The issue is that the function GetDataStore used to return a GlobalDataStore object that wouldn’t cause any harm at all until you attempted to GetAsync etc., and then it would error.

The current behavior is that an error is thrown just for calling GetDataStore. This affects me because my previous expectation was that I could call it unprotected (and therefore did). I think this expectation is appropriate seeing as the wiki article gives no indication that an error would ever be thrown. I think this change was a mistake and am just asking that it gets returned to the previous behavior.

I already fixed my code, but I’m sure there are others that would prefer not be bothered to fix their code too.

That’s interesting as I’ve always had the following line in my code which has always worked:


local Ran, DataStore = pcall( game:GetService( "DataStoreService" ).GetDataStore, game:GetService( "DataStoreService" ), "Partipixel" )

if not Ran or type( DataStore ) ~= "userdata" then DataStore = { GetAsync = function ( ) end, SetAsync = function ( ) end, UpdateAsync = function ( ) end, OnUpdate = function ( ) end } end

I too remember :GetDataStore() erroring in cases where you didn’t use Edit or didn’t publish. I forgot whether this also happens for places you don’t have access to.

Then it could have been a difference between Mac and PC or something.

All I know is that the code in my current project has run in Play Solo completely fine for two years and only yesterday did I have to change it to work.

Also, note that the GetAsync wiki page has a section titled “Errors”, whereas the page for GetDataStore doesn’t mention the word “error” once.

I’ved used studio on both a mac and pc with this code and both worked. I do agree about the wiki page though, it should be updated to note it errors when not published.

Logically speaking, it proves nothing that your code ran on both machines because your code was written on the safe side so you would have never discovered whether there was an error in the first place…

What I meant was, I printed the results of the pcall to make sure it was working, and it returned that it errored on both mac and PC

Ah, I misunderstood. Sorry.

I honestly don’t understand how I am the only person who had no issues with calling it unprotected for this long. It’s time to let it go, though. If this was the way it was meant to be all along, I’ll just comply from now on.

Thanks, guys.

I’ve also been calling it unprotected, since there haven’t really been any reasons to wrap it in pcall.

This error message seems kind of unnecessary and annoying. Perhaps a warning would be more appropriate.

1 Like

This does indeed error, and we’ll update that wiki page when we get to updating the data store pages in general.