Datastore Loss Data Help

Hello I still don’t understand well how to do what you suggested but I try this one which I feel I had many mistakes.

On top of the codes below the declaration of old datastore, I wrote this one

local player = game:GetService(“Players”)
local NewData = DataStoreService:GetDataStore(“NewData”)
–created empty table, im not sure if this should be global or inside the player added function
local data = {}

Inside the game players added function, I didn’t touch anything instead I just added this at the end of the function

if dataSpent then
	Spent.Value = dataSpent
end

--this one
for _, stat in pairs(player.leaderstats:GetChildren())do
	data[stat.Name] = stat.Value
end end)

Then on game players removing, I still didn’t touch anything but added this which I don’t know if correct

earnedCoinsStore:SetAsync(Player.UserId, Player.leaderstats2.Earned.Value)
spentCoinsStore:SetAsync(Player.UserId, Player.leaderstats2.Spent.Value)

--this one	
for _, stat in pairs(player.leaderstats:GetChildren())do
	NewData:SetAsync(Player.UserId,data[stat.Name].Value)
end	end)

On the RemoveAsync, I have no idea how I will write it on my codes.