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)

2 Likes

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

Is this safe for ordered datastores? also what all would change if we were to use ordered datastore

how i can implement session locking to my code ? i understand the idea of session locking but i find it hard to implement it to my script

i tried it and it didnot save with that way

requesting budget means that you check if you can do a certain action and how many times you can do it for example i want to save the players data so before doing that i should see if i can save the data before trying to save it by requesting the budget and see if i have enough budget or not

but this system will make players after leaving the game can not get their data until 30 min pass