I recently made a post here including my script, where I asked about help. Because the DataStore didn't save :(. However, one guy told me to use OnClose, so I ask all of you beatiful fellows, does DataStore require onclose event to save?
COMMUNITY QUESTION
Does DataStore require OnClose event?
1 answer
Accordingly to DataStore ROBLOX tutorial, the closing of the server happens when the last player quits. That means, theorically, that you can't save that last player data when he quits, because the server will end every functions, even if they are yielding. The OnClose() is an even that, when triggered, yields the shutdown, leaving enough time to save.
Conclusion: If the player quits a crowded server (with 2+ players), there's no need to use it, once the other players keep the server from shutting down. If it's the last player, OnClose() comes mandatory.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
OnClose() is required to ensure data saves when the server is closing. However, you are still required to save the data yourself as the players leave.