I’m just going to get straight into whats going on.
My issue is that DataStores2 is not saving when the game shuts down or when a player crashes, yet it saves when I leave the server and rejoin which is super confusing.
I’m new to DataStores2 since I’ve started learning them about 2 or 3 days ago, I’ve also watch a few tutorials. I have asked for help on my issue about 4 times and nobody knows what the problem is, and as a last resort I’m asking help on the dev forums.
When I say nobody knows what the issue is, I mean literally nobody knows.
Here is my code:
local dataStore2 = require(1936396537)
local defaultCash = 0
game.Players.PlayerAdded:Connect(function(plr)
local pointsDataStore = dataStore2("points",plr)
local leaderstats = Instance.new("Folder",plr)
leaderstats.Name = "leaderstats"
local points = Instance.new("IntValue",leaderstats)
points.Name = "Points"
local function pointsUpdate(updateValue)
points.Value = pointsDataStore:Get(updateValue)
end
pointsUpdate(defaultCash)
pointsDataStore:OnUpdate(pointsUpdate)
end)
First impressions about using DataStores2 from this alone is not good and I’m already considering going back to normal DataStores, I hope somebody knows the answer to my problem.
Id also like to say thanks in advance for anybody who spends any time trying to help me.
I’ve tested datastores2 in normal servers many times and like I’ve said before that datastores2 only saves when you leave the game, not when you disconnect or when the server shuts down.
iirc it does (should) save when the server shuts down ( using bindtoclose), so this shouldn’t happen , could this be related to this? if it is , this shouldn’t be the case anymore if you’re using the latest version.
oh then i’m not sure, I don’t really use Datastore2 tbh, but you’ll probably have to look for more information on the Datastore2 article, you could be doing something wrong OR a new ds2 update is broken.
have you set the data first? I don’t think you can update it unless it exists first.
everything works normally as a datastore2 would work
is just that its not saving when the server crashes or disconnects but it loads when you leave the game and rejoin
Having this same issue months later, did anyone find a fix yet? I was under the assumption that DataStore2 saves any data the player might have had during that session when they leave / crash but that does not seem to be happening within my games.
Any feedback from @Kampfkarren would help here, thanks!
Having the same data loss issue, but I was able to fix the :BindToClose() not being called just by moving it out of the__call() function and just moved it further down the script. So that fixed data not saving when shutting down servers, but now having a new issue where the player’s data isn’t saving when they crash. Which is odd because I feel like even if they crash it would either run bindtoclose or playerRemoving to save their data, but for some reason it doesnt? They end up losing hours of progress when they crash, which really sucks :// Did anyone find a solution to data not saving when the players crash??