So, I am building an open persistent world. This requires things that players build to be consistently saved regularly.
With that said, I have a function to save buildings in the world. It both fires every 60 seconds (through while wait(60) do), as well as through a game:BindToClose() function.
The issue is, half the time it just refuses to fire when the game is closing, and that seems to result in a complete loss of data for whatever reason, or at least an inability to load the data. I have scattered print() functions throughout the system, and I haven’t got a clue why it does this. It just outright does not even fire sometimes, and I know this because the very first thing it is supposed to do is print(“Firing”).
Meanwhile, using the exact same script structure and methodology, I am able to use game:BindToClose() to save data regarding a chunk claiming system I have also made.
I know the function itself works - minus the game:BindToClose() issue. Is there something about that function I am missing or not understanding? And why does it result in a complete wipe of data when it fails to even try to save?
No errors, no print logs, nothing. Just doesn’t save and the next time I try to load the game, the data is gone.