How to make it so data saves when a player leaves and they were the only one in it

I made a tutorial regarding exactly this.