I've attempted this and I'm not sure if I am close or not. The script doesn't work. I was just playing with it at the beginning now I want to learn how to fix this so it works.

function CreateData(Player)
if Data[Player] == nil then
	for i,v in pairs(Player.Leaderstat:GetChildren()) do
		if v.ClassName == 'Folder' then
			Data[Player][""..v.Name] = CompileData(v)
		elseif v.ClassName == 'IntValue' or v.ClassName == 'StringValue' then
			v.Value = Data[Player][""..v.Name]
		end
		if v.ClassName == 'IntValue' then
		Data[Player][""..v.Name] = 0
		elseif v.ClassName == 'StringValue' then
			Data[Player][""..v.Name] = ""
		end
		end
	
	
function CompileData(Player, t)
	t = Data[Player] or {}
	for i,v in pairs(Player.Leaderstat:GetChildren()) do
		if v.ClassName == 'Folder' then
			Data[Player][""..v.Name] = CompileData(v)
		elseif v.ClassName == 'IntValue' or v.ClassName == 'StringValue' then
			v.Value = Data[Player][""..v.Name]
			end
		if v.Name ~= "Type" and v.Name ~= "Type2" then
		v.Value = Data[Player][""..v.Name]
		elseif v.Name == "Type" or "Type2" then
		end 
	end
	return(t)
	    end	
	end
end

function LoadData(Player)
 if PlayersLoaded[Player] == nil then
	Data[Player] = DSS:GetAsync(""..Player.UserId)
	function CompileData(Player, t)
	t = Data[Player] or {}
	for i,v in pairs(Player.Leaderstat:GetChildren()) do
		if v.ClassName == 'Folder' then
			Data[Player][""..v.Name] = CompileData(v)
		elseif v.ClassName == 'IntValue' or v.ClassName == 'StringValue' then
			v.Value = Data[Player][""..v.Name]
			end
	end
	return (t)
		end
	end

game.Players.PlayerAdded:connect(function(Player)
    game.ReplicatedStorage.Leaderstat:Clone().Parent = Player
if DSS:GetAsync(Player.UserId) == nil then
	CreateData(Player)
elseif DSS:GetAsync(Player.UserId) ~= nil then
	LoadData(Player)
    end
end)

game.Players.PlayerRemoving:connect(function(Player)
	DSS:SetAsync(""..Player.UserId, Data[Player])
end)