Datastore doesnt work in game, but works on studio

Inside the studio, it saves and loads the data perfectly, but in the game it does not save anything.
(accesorios is a replicatedstorage folder with values.)


I am not very strong in the datastores topic, here what I want to achieve is to save a complete folder of intvalues.
An apology if I suddenly write incoherently, I am using a translator.

Try adding a task.wait(5) at the bottom of the BindToClose() function. Also, you should always use a pcall() when accessing the DataStore, it is a network request and can sometimes fail.

You only have a bind-to-close function to save data.

  • User Players.PlayerRemoving, and save the data. It saves for Roblox studio because you’re testing alone and will automatically save when you stop testing (because the game will shutdown), in a normal game, servers stay for a couple of seconds, pretty sure you’ve come across an empty server at some point in a game. So it will not BindToClose if the last player leaves.