Will this coroutine function run all 3 functions at the same time when the player leaves?

In my code, I’m using the coroutine function to initiate 3 functions to run at the same time. Each of these 3 functions just sets an async to 3 different datastores. Since there isn’t a lot of time from when the player leaves and when all of their leaderstats, playergui, etc. gets deleted, I need these functions to run at the exact same time, and not one after another. So, I did some research on coroutines and here is what I came up with. Will all 3 functions run at the exact same time when the player leaves the game?

function Save(player)
	local ID = currencyName.."-"..player.UserId
	DataStore:SetAsync(ID,player.leaderstats[currencyName].Value)
end
function Save2(player)
	local variable = player.PlayerGui.QuestGui.Frame.MainFrame
	LevelQuestDatastore:SetAsync(player.UserId, variable.Quest2.CoinAmount.Text)
end
function Save3(player)
	local variable = player.PlayerGui.QuestGui.Frame.MainFrame
	CoinQuestDatastore:SetAsync(player.UserId, variable.Quest1.CoinAmount.Text)
end
	

game.Players.PlayerRemoving:Connect(coroutine.wrap(Save), coroutine.wrap(Save2), coroutine.wrap(Save3))

I mean just use a print(‘Hello’) to test it, if it doesn’t work then post it here. I’m not 100% sure tbh but it should!

I’m 99% sure it will. Do what @legspc did, and test it!

For some reason the third function is not saving in time before the player leaves, and the data is reset when the player joins the game. Is it because it’s the last function, which means it saves last? Aren’t coroutines supposed to run at the same time though?

I believe you can only connect a single function to the event, so you have to either make the player removing event for all 3 of them or just run them from 1 function

function Save(player)
	local ID = currencyName.."-"..player.UserId
	DataStore:SetAsync(ID,player.leaderstats[currencyName].Value)
end
function Save2(player)
	local variable = player.PlayerGui.QuestGui.Frame.MainFrame
	LevelQuestDatastore:SetAsync(player.UserId, variable.Quest2.CoinAmount.Text)
end
function Save3(player)
	local variable = player.PlayerGui.QuestGui.Frame.MainFrame
	CoinQuestDatastore:SetAsync(player.UserId, variable.Quest1.CoinAmount.Text)
end
	
function SaveAll(player)
	coroutine.wrap(Save)(player)
	coroutine.wrap(Save2)(player)
	coroutine.wrap(Save3)(player)
end

game.Players.PlayerRemoving:Connect(SaveAll)

Although not sure how much it’ll help to save all the data, cna’t you just use a single datastore and save a table of stuff instead of 3 separate datastores?

Hmm, it’s probably attempting to run, but not able to finish before the client is removed.

I can, but I usually like to keep different things separate (for example leaderstats from quest stats) It’s just more organized.

Putting all the coroutines in a SaveAll function still didn’t work for me, the third coroutine didn’t fire in time before the client was removed. Any other ideas?