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


#102

Try replacing local Inventory = Data:Get() with local Inventory = DataStore2("Inventory", Player):Get(), perhaps there is an issue with caching/differing keys?


#103

In any particular block or both?


#104

Second one.


#105

Still doesn’t work. Might just try recoding it all to see if it fixes ;p


#106

Can you add documentation on how to use ODS with this? Or give me the basic run down on how I would do it. Thanks.


#107

You wouldn’t be able to because of how DataStore2 saves internally, apologies.


#108

Ahhh thanks for the clarification I re-read the documentation multiple times thinking I missed something. So would it be alright if I used a separate ODS alongside Datastore2 or would the rates be hit?


#109

As long as you’re smart about using 1 DataStore2 key (or use combined data stores), no.


#110

Alright thanks for the clarification! Also really loving Datastore2


#111

Is it possible to create a leaderboard with DataStore2? Like in games that shows the top 10 "insert action here"ers ?


#112

As I said before, DataStore2 has no functionality like ordered data stores. It’s best to just use normal ordered data stores for that, sorry.


#113

Rip, might leave a leaderboard out then. Thanks for the fast reply.


#114

If you aren’t doing too many data store calls, you can just read players’ data from DataStore2, and save it to a regular ordered data store.


#115

Been using this on a few of my projects, and I have to say it works great. Never had any issues in the few months of development I’ve been doing. Good stuff!


#116

I’m having a small issue here. I’m trying to check to see if there is a cached value and if not it tells the client to do stuff.

Code below

DataStore2.Combine("MasterKey", "Avatar")
	
	local Avatar = DataStore2("Avatar", plr)



	if not Avatar:Get({},true)  then
	print('Player has no avatar data')
	game:GetService('ReplicatedStorage').Remotes.RemoteEvents.CustomizeAvatar:FireClient(plr,"New")

	end

help is appreciated


#117

Is this really what you want? If you don’t provide a default to Get, it’ll return nil which may be what you want. I don’t see why you’d need to check specifically to see if there’s a cached value in the first place.


#118

To check if its the player’s first time playing by checking if the player has data.


#119

Then just check if the result of :Get() is nil.


#120

thanks


#121

Added a little note at the beginning: