DataStores - Beginners to Advanced

pcall has 2 arguments, the function and the arguments you want to pass in (optional)
pcall(dataStore.GetAsync, dataStore, key); its just the same as

pcall(function()
    return dataStore:GetAsync(key)
end)

if you got confused with, why pass in the dataStore? any method in a table/object has its functional part, when you do dataStore:GetAsync(key), dataStore is being passed in as the first parameter even tho you don’t see it, which is equal to dataStore.GetAsync(dataStore, key)

1 Like

Ahh I see thank you for telling me!

1 Like

im going to try and understand the code, so i can implement something like this in future projects

thanks for the help (:

i dont get making a datastore, or get async

elaborate on what you don’t get. “making a datastore” is just fetching it, or if its not found, then create the datastore. get async takes a key argument, it fetches the value in the datastore, with the provided key.

{
    datastore1 = {
        hello = 'world'
    }
}

in this example, if you want to get the hello value, first use :GetDataStore(), then use :GetAsync(“hello”) on the datastore