Data not saving in roblox studio

So I made a post earlier in regarding to this, and it was fixed eventually for a little while by using “game:bindtoclose”, and with a coroutine you could loop trough all the players to store their data by using “setasync”. But now for some reason it just isn’t working anymore in roblox studio. If I join my game on the platform it works perfectly fine though, just not in roblox studio.

I have tried to find a solution by searching trough the dev forums, but I couldn’t find anything that would fix my problem. So I hope somebody here can.

rb8

3 Likes

the game closes before it has time to save the data inside “BindToClose” function.

basically the game closes once “BindToClose” function finishes running and so “coroutine.wrap” is not waited to finish.

Here’s a new example I created.

game:BindToClose(function()
	print('Started.')
	local coroutines={};
	for _,v in game.Players:GetPlayers()do
		local c=coroutine.create(SaveData);
		table.insert(coroutines,c);
		coroutine.resume(c,v);
	end
	for _,v in next,coroutines do
		repeat task.wait()until coroutine.status(v)=='dead';
	end
	print('Finished.');
end)
2 Likes

I tried it out, but it still doesn’t work in roblox studio :((

I was testing out my code, and I tried to find to see where thing started to go wrong, and basically nothing will run anymore after setasync is being used. But this poblem only occurs in roblox studio, and I am just very confused.