Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

are there any alternatives to game.OnClose() ?

So i need to save data using datastores, but i need to save something really important when the last player leaves the server,

so i stumbled upon this on the roblox wiki:

game.OnClose = function()
	print 'Closing, waiting'
	wait(3)
	print 'Done'
end

The wiki says that "item" is depreciated and not to use it for new work, however, i'm confused by this. Are there any alternatives to this and if not, would this function still work?

Thanks.

1 answer

Try this: When a player is leaving, with PlayerLeaving(), Check the number of players, game.Players:GetChildern(), then do your datastore saving.

1 comment

0

or #game.Players:GetChildern()

This discussion is preserved as it was. New answers, comments, and votes are closed.