Comments (9)
Can you try this and see what happens (best if it works on a slightly modified baseplate):
- Join server
- Change data in some way so that it actually saves
- Shut down all servers
- Quickly join back
- Observe your data is the old data
- Do NOT change your data
- Leave, it won't save if data isn't changed
- Join back later
What data do you get? Old data or the data from when you shut down? My theory is it's still saving by the time people rejoin.
from roblox.
I followed the steps and got the old data.
from roblox.
@Intrance1 That's strange--and it says in the console it didn't save because of unchanged data, correct? DataStore2 runs code on BindToClose, so there could be something incorrect there.
from roblox.
There's nothing in the log after the game is shutdown. I'm not sure if messages continue to be posted to the console after the server is shutdown. The message could be posted after I'm kicked from the server and that could be why I don't see anything in the console.
from roblox.
Can you see what happens when you add this somewhere in your code:
game:BindToClose(function()
dataStore:Save()
end)
I wonder if it's a BindToClose problem or a DataStore2 problem.
from roblox.
That worked. I shutdown the server and "saved key" outputted in the console, then rejoined and had the correct data.
from roblox.
Strange, that means it must be an issue with how DataStore2 specifically implements it. Not so coincidentally, there's also no unit tests for it.
Here's the relevant lines:
Lines 619 to 644 in 56a0d27
It's a bit weird, but the gist of it is:
- When the player leaves (ancestry changed and they're no longer in the data model), set a "fired" flag to true after it has been saved and fire an event.
- On BindToClose, if the player hasn't successfully saved yet (the "fired" flag), wait for them to save.
This logic makes sense to me, so I'm not sure why it isn't working. While we could just call :Save()
twice, this would fire two requests to save the data, which would add additional overhead.
from roblox.
So I was doing some testing with the playerLeavingConnection and I think the problem is with the AncestryChanged event. I replaced it with a PlayerRemoving event and that worked.
from roblox.
That must be it, the AncestryChanged patch is recent: 620688e
Thanks for you research! I'll fix it when I can unless you want to make a stab at a PR (that also fixes the memory leak the previous version had).
from roblox.
Related Issues (20)
- deploy github pages
- Complete data loss when joining a private server HOT 2
- Is it possible to realize the table structure by combining multiple times? HOT 4
- Use other Keys than player HOT 6
- Datastore() function reads datastore name as a table HOT 1
- Can we use player IDs instead of a player object? HOT 1
- No-Scope Arcade uses Datastore2
- Add Slide World to used games
- ` ServerScriptService.DataStore2:485: DataStore2() API call expected {string dataStoreName, Player player}, got {string, nil} ` HOT 2
- :BeforeSave() doesn't get called if the datastore hasn't been updated
- Getting an issue when using DataStore2 HOT 1
- Im confused HOT 1
- Does DataStore2 Support HOT 1
- Global Leaderboards HOT 1
- Combine is not a valid member of ModuleScript HOT 2
- 123
- nvm x.x
- Saving to a table HOT 1
- Magic training
- Zelda
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from roblox.