How to use DataStore2 - Data Store caching and data loss prevention

DataStore2 does not support cross-server communication.

1 Like

:+1: Thanks! Not that I needed it, but helpful to know.

2 Likes

If you were going to ‘edit’ any of the values you created for the datastore, (such as ‘points’) in a different script, would you need to require the module, and use :Increment() to add to the value? Or could we simply just use math?

I’m not sure what you’re asking? The values are the same across different scripts if you use :Get().

I mean would I have to do:

randomvalue.value = randomvalue.value + 5

or use:
randomvalue:Increment(5)

my question is, do I have do use :Increment() in a different script besides the Datastore2, or would I still have to require() the datastore, in the new script I’m using and then use :Increment()? Or could I simply do it the traditional way of using math to add?

:Increment sets the value, just grabbing the value and adding won’t set it. If you need to set the value, use :Increment, otherwise traditionally add.

1 Like

Well after watching AlvinBlox’s tutorial and explanation, he states,
“You can use :Set() to set the value, like, :Set(500) will set to 500 every time, if you use :Increment(500) it’ll add 500 instead of setting the value to 500”

Yes, like in the thread:

3 Likes

I am making the model a package so that it’s easier for developers to update their copies and eliminates one of the reasons to require by ID. Hopefully everyone who is requiring by ID can still do so, but please tell me if this messes up anything!

image

5 Likes

Great project but please implement cross-server communication. Most developers don’t really need to do anything other than reading/getting data from the server, for me anyways I handle all data setting on the server all I do is just fetch data from the client to update UI and etc, I know I could use :OnUpdate and keep sending info to the client and the client can update UI but having it built-in would be very nice.

1 Like

Do you mean network communication and not cross server communication?

1 Like

Mhm, I misworded it.

1 Like

I suppose a feature like that would be neat, but not something I’d prioritize right now. :OnUpdate and a RemoteEvent seem like the best way to do it.

2 Likes

Well thanks for the quick response, also a system for easily loading backups onto main datastores would be neat, I haven’t look at much of your code but I don’t believe it is currently possible. Would be useful for if by chance data loss did happen and you needed to load a backup.

3 Likes

Scratch this, apparently it didn’t save as a package at all??

1 Like

Going to push out a feature that might break some existing compatibility.

Answer this: do you use BeforeSave/BeforeInitialGet/AfterSave on a combined data store? Preferably also tell me what for if yes.

  • Yes
  • No

0 voters

4 Likes

A new update for DataStore2 is coming out, with mostly internal changes. Your combined data stores should load faster after the update. Please tell me if anything breaks!!!

Update: People are having issues, so I’m reverting the changes. If you can, please use the un-reverted version from GitHub and tell me if you have issues.

7 Likes

Updated again after someone on Discord helped isolate the issue (Get() was calling OnUpdate for combined data stores).

2 Likes

Thanks, I just found out about this and am definitely going to use it

7 Likes

It’s the best

5 Likes