SetAsync seemingly not firing?

Greetings,

local success, errormessage = pcall(function()
		print "async"
		myDataStore:SetAsync(player.UserId.."Data",Data2)
		print "asynced"
	end)

last few days this same script sometimes works sometimes doesn’t. When i first made it worked fine. Then it would only print “async” but not “asynced” and wouldn’t save data. Then yesterday it worked fine again and this morning it worked fine until like 30 min ago it stopped working again, printing only “async”. Is Roblox the issue or is it me?

Thanks for your time

I don’t know, a lot about programming, but when it doesn’t work again, did you close the server?

nah i’m using it in studio only atm

But have you tried it in the game, without being in roblox studio?

well ok i’mma try now but i don’t think it will make a difference tbh

touche good sir, you were right. Seems to save fine in game.

if you want to save in studio (not just in game), you can use game:BindToClose() like this:

game:BindToClose(function()
	for i, player in pairs(game.Players:GetPlayers()) do
		--saving code
	end
end)

This is because studio closes the game and doesn’t remove the player.

thanks for the tip, tho it doesn’t matter too much, so long as it works in game

true, but thought it helps to save in studio too.