Hi, I’m getting reports of some people’s data not saving though I can’t reproduce the issue. I’ve tracked it down to the function OrderedBackups:Set and it has to do with one of the pcalls returning false. There is no difference between the two, so how would I go about debugging this?
One of the pcalls (the one below) I added RankedInfoATFloors:SetAsync(value.userId, value.totalFloors) to, which updates my leaderboards. This has always worked in the past though so I don’t know why it would break for some people. Take a look below:
local success, problem = pcall(function()
RankedInfoATFloors:SetAsync(value.userId, value.totalFloors)
self.dataStore:SetAsync(key, value)
end)
The error I’m getting is on line 386 of the main DataStore2 module with “save error! Argument 1 missing or nil”. I found that this error came from calling the OrderedBackups:Set function I mentioned above.
I don’t know what line 386 is if you messed with the code yourself (which by the way, means you have to open source your entire fork of the module). I definitely would not recommend editing the original code to begin with, you’d be better off just using AfterSave and setting the ordered data store then.
I didn’t modify the original module, I only added the line to the OrderedBackups saving method that saves the data to the leaderboard (does that count as part of the module?). Also, I’m guessing AfterSave is fired after that part in the saving is completed?
@Kampfkarren Is it better to call :Get() for every value saved in a DataStore to update the leaderstats and update the UI showing the value too, using FireClient() on OnUpdate
or
should I only call Get() for updating the leaderboard value and using a .Changed Event to detect the values being changed and then update the UI without calling Get again?
Will too many Get calls used like this cause throttling or something?
Thanks to Datastore2, my game had not even a single data loss, without Datastore2 I would have kept loosing data each day, now everything is stable, no longer need to restore data for each player. Datastore2 saved me a lot of troubles. Thank you again for making this awesome creation!
And Firing an event for every Client each time every value changes using :Get() is a good idea to update UI containing those values? I know OnUpdate exists, but this is to update stats on the Client, which can’t access the module so I can’t require DataStore2 and get the value using Get(), I fire for every Client OnUpdate each time a value changes, won’t this exhaust some sort of limit for firing for every Client?
In the documentation , there was an example showing how whenever a value changed, using OnUpdate an event was fired for the player using a function CallRemote() to update values on the Client.
I’m a little confused to the use of “Datastore2.Combine”, still.
If I have two scripts in ServerStorage and they both independently use the same datastores, should I call “Datastore2.combine(main, store1, store2, store3, store4)” in both of the scripts? Or do I only need to call this in one of them?
so basically calling through remotes for every client is better than using a .Changed event if you are already updating the leaderstats through OnUpdate, to display the latest value in a GUI component?
It can. If you searched “datastore2 data store editor” you would have found a solution. The data store name is dataStore2.Name .. "/" .. dataStore2.UserId so that means if I join your game and your game has "coins" data then you would do "coins/129574502"