What is better to use?
require(id) or just put it in server script service and require it from there?
(What do you suggest mainly?)
It’s better to require the module directly from serverstorage (or another place where you’ve put the modulescript). If you require by ID you have the risk that code could be pushed which results in backwards incompatability with code which is not prepared for it.
If you are referring to all APIs of DataStore2, follow this link.
The part you have selected is the :SetBackup() API which can be used to set a maximum of tries to get data from the roblox datastores.
Is there any way to access the same datastore through multiple scripts?
Also tables
Yes, you can access them the same way you do in all scripts.
Is there any quick hand to updating the value of a dictionary inside of the data table? My code right now is
local dataStore = ds(key,plr)
local data = dataStore:GetTable(defaultData)
data.stats.missedFlights = data.stats.missedFlights + 1
dataStore:Set(data)
I’m not sure if I’m missing anything
This should be alright. You could however choose use .Combine() with seperate DataStores to easily access them without calling the whole table, changing one value and setting the table. This way you could also use for example Datastore:Increment(value)
When downloading the rbxmx
file of DataStore2, does it automatically update or what is the best way to get an up-to-date copy of data store 2.
I have been doing it manually every week.
Just watch the repository on GitHub for releases, you’ll get a notification when it updates.
One other question: Is it possible to manually edit data using Crazyman32’s data store editing plugin? I’m using :GetTable and storing everything as one table. If so what’s the datastore name and key? Asking because I plan on hosting events and stuff that give users rewards. I looked through the code and I’m not quite sure how to access the data.
Edit: Got it. Will the number always be 1 or does it change? Code mentions os.time() and I’m not sure how that applies here.
Is an actual value needed for datastore2 to work?
By that, I mean, if you actually need to put an IntValue in ServerStorage for example and after that, it can save, or can you just save number,string or bool data without any actual value in explorer?
It’s not always 1. Please read this on using the data store editor: How to use DataStore2 - Data Store caching and data loss prevention - #287 by Kampfkarren.
Value objects are never used in DataStore2 except for the SaveInStudio flag.
I’m currently working on a new project and I was wondering if its recommended to use the OrderedBackups or Standard setting.
Personally, I haven’t had any problems using OrderedBackups, and it’s saved me a few times when players report data loss (because I use the module incorrectly) and I can easily revert their data back. It’s also battle tested, I’m not sure if any high profile games use Standard. My suggestion is if you use plenty of other ordered data stores, Standard is your only choice. Otherwise, use OrderedBackups.
Is it ok if I take some data (value, string, bool) a few times (more than usual). Will that cause lag? By “more than usual” I mean, if somebody clicks a button, it would request data, if someone dies and respawns, etc. What’s suggested limit if so?
2nd: Is there still chance that users lose their data?
:Get() only calls a data store request the first time you use it, and :Set() calls data store requests never. Using methods frequently is essentially the same as just setting a variable, so you’ll be fine.
@Kampfkarren
Is there any function that is similar to this
local DataStore = game:GetService("DataStoreService"):GetOrderedDataStore()
local 1To100 = DataStore:GetSortedAsync(false, 10)
What I mean is
I’m trying to get the data from the server and transfer it to the client and my issue will be fixed if there is a similar function like :GetOrderedDataStore() I need a similar function for this to function my leaderboard.
EDIT: Using The :Get() Function Will Not Work I need the function to be global not local and is there a Similar Function Like :GetSortedAsync().
Sorry for the bad English.
Reminder: Check the code for better towards on understanding my problem
Thanks.