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
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.
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…
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.