Leader board not working

I can’t seem to find out what’s wrong with my leader board, it was working perfectly fine before I implemented abbreviated numbers.

Basically when I test the script, nothing shows up on the leader board, nothing in the output.

I have looked through lots of forum posts but they don’t seem to link with my problem.

leader board script:

local abbreviations = {
	N = 10^30;
	O = 10^27;
	Sp = 10^24;
	Sx = 10^21;
	Qn = 10^18;
	Qd = 10^15;
	T = 10^12;
	B = 10^9;
	M = 10^6;
	K = 10^3
}


function abbreviateNums(number)


	local abbreviatedNum = number
	local abbreviationChosen = 0


	for abbreviation, num in pairs(abbreviations) do

		if number >= num and num > abbreviationChosen then

			local shortNum = number / num
			local intNum = math.floor(shortNum)

			abbreviatedNum = tostring(intNum) .. abbreviation .. "+"
			abbreviationChosen = num
		end
	end

	return abbreviatedNum
end

local ds = game:GetService("DataStoreService")

local coinsODS = ds:GetOrderedDataStore("PlayerData")


local timeUntilReset = 1


while wait(1) do
	
	
	timeUntilReset = timeUntilReset - 1
	
	
	if timeUntilReset == 0 then
		
		timeUntilReset = 90
	
	
		for i, plr in pairs(game.Players:GetPlayers()) do
			
			coinsODS:SetAsync(plr.UserId, plr.leaderstats.Coins.Value)
			wait()
		end
		
		for i, leaderboardRank in pairs(script.Parent:GetChildren()) do
			
			if leaderboardRank.ClassName == "Frame" then
				leaderboardRank:Destroy()
			end
		end
		
		
		local success, errorMsg = pcall(function()
			
			local data = coinsODS:GetSortedAsync(false, 50)
			local coinsPage = data:GetCurrentPage()
			
			for rankInLB, dataStored in ipairs(coinsPage) do
				
				
				local name = game.Players:GetNameFromUserIdAsync(tonumber(dataStored.key))
				local coins = dataStored.value
				
				if coins > 999 then
					abbreviateNums(coins)

				end
				
				
				local template = script.Template:Clone()
				
				template.Name = name .. "Leaderboard"
				
				template.PlrName.Text = "@"..name
						
				template.Rank.Text = "#" .. rankInLB
				
				template.Coins.Text = coins
				
				template.Parent = script.Parent				
			end			
		end)
	end
end