Datastorage issues

The most basic about this service:

The DataStore service is divided into two, normal DataStore and OrderedDataStore, both can save and load information that must be string, boolean, tables or numbers.

First you must “find” the “folder” of the data, this is done like this:

local DSS = game:GetService("DataStoreService")
DSS:GetDataStore(Name,Scope)
DSS:GetOrderedDataStore(Name,Scope)

Name is the “folder” and Scope is a subfolder in Name, Scope needs to be defined if you don’t want.

The most basic, to obtain a data use :GetAsync() and to save it use :SetAsync() and to remove it use :RemoveAsync().

There are other properties you can use like: UpdateAsync() and :IncrementAsync().
UpdateAsync: returns the old value and saves the new one you put.
IncrementAsync: it only works with numbers, add the number you put in and return the new value.

Use pcall to catch errors, such as nil values.

More information: Datastore Tutorial for Beginners

1 Like