How would I link this problem with Ordered data stores and MarketplaceService?

So, I wrote some code that worked for ordinary data stores, until soon realising it needed to be in an ordered data store. So, I changed some of my code around but majority of the code just isn’t working. I have it so that when the player buys a Dev product, the amount will be calculated and added onto the amount they have already purchsed. This will then be displayed on a leaderboard.

The leaderboard completely works and there is no problems with that, it is just the saving aspect, I have no idea why it doesn’t work. I will post the code below.

-- // variables //
local MarketplaceService = game:GetService("MarketplaceService")
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")

local DonatedDataStorage = DataStoreService:GetOrderedDataStore("DonatedDataStorage", 1)
local AmountDonated = Instance.new("IntValue")
AmountDonated.Parent = game:GetService("ServerStorage")
AmountDonated.Name = "AmountDonated"
local Data


-- // functions //
local function ProcessReceipt(ReceiptInfo)
	local Player = Players:GetPlayerByUserId(ReceiptInfo.PlayerId)
	local PlayerId = ReceiptInfo.PlayerId
	local PlayerName = Players:GetNameFromUserIdAsync(PlayerId)
	local Cost = ReceiptInfo.CurrencySpent
	
	if not Player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	
	if Player then
		local success, errormessage = pcall(function()
			local Pages = DonatedDataStorage:GetSortedAsync(false, 10)
			local TopTen = Pages:GetCurrentPage()
			
			for rank, data in ipairs(TopTen) do
				print("Hello")
				local name = data.key
				local amount = data.value
				local rank = rank
				print(name.." "..amount.." ".. rank)
			end
		end)
	
			if success then
				local Cost = ReceiptInfo.CurrencySpent
				local NewData = Data + Cost
			
				local success, errormessage = pcall(function()
					DonatedDataStorage:SetAsync(tostring(PlayerName), NewData)
			end)
			
			if success then
				print("Player has donated: "..Data)
				return Enum.ProductPurchaseDecision.PurchaseGranted
			end
		end
	end
end



-- // events //

MarketplaceService.ProcessReceipt = ProcessReceipt