Module not loading

That’s a non-problem. OP would’ve caught that in the Developer Console if they printed out the error message - the “GetASync is not a valid member of GlobalDataStore” is not being thrown because it’s wrapped in a pcall. The issue is specifically with the SetAsync statement below it.

Oh wow, nice spot! :smiley:

However, this sadly isn’t the only issue. It seems there are a couple more errors further down in the script (This can be seen because of colbert’s print debugging).

@colbert2677 please keep in mind that you would need to GetAsync before SetAsync, and with an error in GetAsync, how will SetAsync work correctly?

What are you talking about? You do not need to run GetAsync before you do SetAsync. Getters and setters are two different functionalities altogether and are not dependent on one another. GetAsync returns a value from the key you specify. Set enforces a value to a key. Just because GetAsync errors, that doesn’t mean the same will happen for SetAsync.

2 Likes

Okay, I think I might’ve figured out the flaw regarding this script. I tried running a unit test again, since my first run was flawed. Just as my suspicions confirmed, I went and refurbished the pcall statement - the error is in the SetAsync method. Though this unit test was a little different.

I simply toggled this. OP… do you have this enabled? You can’t use DataStores in Roblox Studio without this enabled. I toggled it and I received no errors at all.

5 Likes

It seems I have maybe goofed up.

Thank you for pointing out the API activation… I am now a “prize plonker”.
Once again, thank you so much for pointing this out.:heart:

1 Like

Remember that in the future, anything that’s internally a web call (such as DataStores), you’ll want to wrap in pcalls due to their potential to error. Since you already seem to be doing that, make sure you make the most out of pcalls by making use of its return values for debugging purposes; the success bool and the results of a pcall.

Truthfully I didn’t understand the issue but after figuring out that nothing was wrong with your code, I knew there was an external issue. It was only until I modified your GetAsync pcall that I figured out what was happening.

local success, result = pcall(function ()
    return GetAsyncStatement
end) -- If it succeeds, returns GetAsync value, otherwise an error

print(success, result) --> false & HTTP 500-code regarding unauthorised access
1 Like

Alright, thanks for the advice. :+1: :smile: :+1: