Problem with my script for Datastore

yeah but i learned (copied) from the youtube video, they can’t be wrong right?

It depends on the amount of views, the video’s age, and the comments, you can’t trust youtubers completely. You can try my script and tell me if it works.

i mean the video is quite popular! And well explained!

Have you tried using the BindToClose function? It’s an event that pauses the game and lets some run code, including task.wait()s:

game:BindToClose(function()
    task.wait(5)
end)

This waits 5 seconds before entirely closing the game, to let the data save. Put this code before anything else, so it works properly.

Okay this is getting a bit off topic, if you want to discuss about the video then we can do it in DMs.
By the way have you tried my code yet? Mark the code as a solution if it works

It’s a problem with loading data, not saving data. Still a good way to prevent data loss though

Uhh well nope it didn’t work out:(

Yeah but why we need to pause the script?