Datastore in *studio* doesnt save on regular playtest, does work if its 2 players - PlayerRemoving

Hello!
I was working with a simple datastore that saves time & money, however, as of recently it no longer saves in a regular playtest in studio.

  • It used to save fine when the script was originally made but not anymore.

  • Loading works perfectly fine!

  • I have tested it ingame, it saves fine ingame. this only occurs in studio solo playtest

  • It does save correctly if you do a local 2 person playtest though, so I’m pretty sure the code isn’t the issue.

It saves via Player.PlayerRemoving

Video of the issue:
As you can see it will only print their username but nothing else will happen on a regular playtest but it works fine on the 2 player one.

Repo file:
datastore test.rbxl (55.1 KB)

1 Like

Studio has significantly improved in load times lately and other areas of delay/slowness.
A server in a quick play test was always cleaned up right away, sometimes however studio was slow enough that it got a chance to save before being cleaned up. There has always been some confusion especially for “beginners” when it sometimes saved, and sometimes didn’t.
The improvements in studio simply causes it to be shut down much quicker, giving no chance for data to be saved.
I’m pretty confident this has always been intentional behavior for the server to shut down as quick as possible, so you can get back to edit mode with no delays or additional resources being taken up in the background.

This will never be an issue in-game, Roblox purposefully give the server time before fully shutting down. It’s also ideal to always occasionally save data during play as the server may crash, or other issues which makes it unable to save data.

In a multiplayer server test, players are cleaned up before the server, giving it some time to save before shutting down.

2 Likes

Add this somewhere in the script

game:BindToClose(function()
    if game:GetService("RunService"):IsStudio() then
        task.wait(3)
    end
end)
2 Likes

I assumed it had something to do with the server shutting down too fast to resume scripts as even regular prints didnt print, thank you for sharing! I didn’t know roblox made any improvements to that.

1 Like

If you’re binding to close, instead of task.wait(3) which will slow down your studio by 3 seconds, I recommend just making sure you wait until your :SetAsync() or :UpdateAsync() call is completed. This will take less than 3 seconds typically, saving you valuable time while testing.

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.