Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Does DataStore require OnClose event?

Asked by 8 years ago

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?

0
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. DevSean 270 — 8y

1 answer

Log in to vote
0
Answered by
davness 376 Moderation Voter
8 years ago

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.

Ad

Answer this question