I am doing some testing and fixing in Studio, and I saw that changes are not being saved. I tested the issue in a live game, and the changes did save just fine. I started this project a long time ago, and the data stores worked fine.
Also, I just checked, and the game failed to read from the data store, so now the game thinks I’m a new player because it saved the game that way (no big deal, it’s just for testing).
Studio does save data, but most of the time it fails. If it doesn’t work in game then that’s a scripting issue. The only time a datastore fails is when many games have data unable to load.
Are you the owner of the place?? Roblox has a rule which only the owner of the place can do this, anyways sometimes roblox studio can’t run data stores very well try it again after 24 hours it might be fixed
Generally, servers in studio shut down before saving can occur (especially in solo play). My recommendation for testing datastores in studio is to run a local test server and leave with the player before shutting down the server. That way, the methods will have a chance to save the data before the server shuts down. You cannot use BindToClose in studio, so that’s why this is the solution I recommend. This was an issue someone I helped recently had and it’s easily resolved by testing in the way that I described.
As I have corroborating evidence from multiple other developers, I can only conclude that your successes have been a fluke. In solo play testing, the server will sometimes shut down before the save function can take place. This is not always the case, but it sometimes is.
For me studio does not save all the time when I leave play solo (it does save occasionally). If my game try’s to save while I’m in play solo it works. Just when I leave it doesn’t seem to fire the player.playerRemoving event.
I’ve later concluded that the DataStore API will indeed not save when Solo Play testing. I’ve realized that my tests that I’ve done had a wait() whenever a player leaves to save the players data, so my tests were indeed at fault here. Sorry for the excess and unprofessional behavior I’ve been displaying about that throughout.
So in the OP’s case, they would have to add some sort of delay before saving the players data if they want to have data save from Roblox Studio. Roblox servers save even without the delay so even if Studio wouldn’t save the data, at least actual Roblox servers will.
The OP can also use game:BindToClose() to save all players data but I doubt this will work. My tests concluded that it did but it isn’t always the same for everyone.
it doesn’t save because of how fast the player leaves the game when you stop the simulation in studio which means the PlayerRemoving function wasn’t even fired to begin with, if you kicked the player from the game, the PlayerRemoving function would then work, try kicking the player instead of stopping the simulation for the game to have the chance of detecting the player leaving and saving their values.
Make sure you have a BindToClose function along side the PlayerRemoving. Something I noticed is that the server doesn’t always Disconnect fully in studio (or something like that), sometime the server would say disconnect (that’s when it would work) and sometimes it wouldn’t. If you use BindToClose it should always work.