Answered by
5 years ago Edited 5 years ago
To load:
Create a new Datastore2, which we'll store in DS.
Call :GetTable() on DS, with a table of defaults inside, and do whatever you want with the result.
- If any key inside of defaults is not found in the data receiver from :GetTable(), it'll be added to the data.
To set:
Gather all the data that you want to set.
Create a new Datastore2, which we'll store in DS once again.
Call DS:Set() with the table containing player data as argument.
To save:
Create a new Datastore2, which we'll store in DS
Then, call DS:Save()
Code sample:
01 | local DataStore 2 = require( 1936396537 ) |
05 | local DS = DataStore 2 ( 'PlayerData' ,Player) |
06 | return DS:GetTable(Defaults) |
10 | local DS = DataStore 2 ( 'PlayerData' ,Player) |
16 | local DS = DataStore 2 ( 'PlayerData' ,Player) |
Please note:
Usually, you don't call a save function using Datastore2, instead, you set the data, and Datastore2 will save it at the end of the session. You should only call a save function if something important needs to be saved