Leaderboard isn't setting image

I have a global leaderboard in my game that works perfectly and now i’m trying to get it to also display an image of the player with the rank, but when I edit the script to do so, it just does not work, and does not show anything, can somebody please help me on this? Also, it does not come out with errors so I can’t see what’s wrong.
Script:

local ds = game:GetService("DataStoreService")

local coinsODS = ds:GetOrderedDataStore("CoinsStats")


local timeUntilReset = 10


while wait(1) do
	
	
	timeUntilReset = timeUntilReset - 1
	
	script.Parent.Parent.ResetTime.Text = "Resetting in " .. timeUntilReset .. " seconds..."
	
	
	if timeUntilReset == 0 then
		
		timeUntilReset = 10
	
	
		for i, plr in pairs(game.Players:GetPlayers()) do
			
			coinsODS:SetAsync(plr.UserId, plr.leaderstats.Survivals.Value)
		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, 10)
			local coinsPage = data:GetCurrentPage()
			
			for rankInLB, dataStored in ipairs(coinsPage) do
				
				
				local name = game.Players:GetNameFromUserIdAsync(tonumber(dataStored.key))
				local userid = (tonumber(dataStored.key))
				local coins = dataStored.value
				local thumbType = Enum.ThumbnailType.AvatarBust
				local getthumbnail, isReady = game.Players:GetUserThumbnailAsync(userid, thumbType)
								
				local template = script.Template:Clone()
				
				template.Name = name .. "Leaderboard"
				
				template.PlrName.Text = name
				
				template.Rank.Text = "#" .. rankInLB
				
				template.Coins.Text = coins
				
				template.PlrIcon.Image = getthumbnail
				
				template.Parent = script.Parent				
			end			
		end)
	end
end

Any output error from the script?

No, which confuses me, but the leaderboard worked perfectly before, but now it shows nothing

all im trying to do is make it also display an image of the player

This could mean another script is overwriting it if it was working from before

that cant be true though because im only trying to get the user id, making the player thumbnail, and setting the image with the thumbnail of the usedrid, maybe its something wrong with me trying to get the uder id but since i’m not to advanced at scripting i dont really know

i actually printed the dataStored.key and its correct but i dont know why it isnt setting the image to the players thumbnail even though it already has the thumbnail defined with the user id

Try printing “errorMsg” to see if there actually is an error.

does it not already do a pcall and erromsg? or where should i let it print the error msg

After the pcall closing statement. Specifically this end with the parenthesis. image

is it print(error)? or something else

print(errorMsg) because you defined it along with success in your pcall.image

so like this

   end
 print(error)
end)

now its saying unknown global errorMsg

No. It would be print(errorMessage). Your full code after the modifications should look like this:

local ds = game:GetService("DataStoreService")

local coinsODS = ds:GetOrderedDataStore("CoinsStats")


local timeUntilReset = 10


while wait(1) do
	
	
	timeUntilReset = timeUntilReset - 1
	
	script.Parent.Parent.ResetTime.Text = "Resetting in " .. timeUntilReset .. " seconds..."
	
	
	if timeUntilReset == 0 then
		
		timeUntilReset = 10
	
	
		for i, plr in pairs(game.Players:GetPlayers()) do
			
			coinsODS:SetAsync(plr.UserId, plr.leaderstats.Survivals.Value)
		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, 10)
			local coinsPage = data:GetCurrentPage()
			
			for rankInLB, dataStored in ipairs(coinsPage) do
				
				
				local name = game.Players:GetNameFromUserIdAsync(tonumber(dataStored.key))
				local userid = (tonumber(dataStored.key))
				local coins = dataStored.value
				local thumbType = Enum.ThumbnailType.AvatarBust
				local getthumbnail, isReady = game.Players:GetUserThumbnailAsync(userid, thumbType)
								
				local template = script.Template:Clone()
				
				template.Name = name .. "Leaderboard"
				
				template.PlrName.Text = name
				
				template.Rank.Text = "#" .. rankInLB
				
				template.Coins.Text = coins
				
				template.PlrIcon.Image = getthumbnail
				
				template.Parent = script.Parent				
			end			
		end)
        print(errorMsg)
	end
end

alright so it says this
Argument 3 missing or nil

Since that error is somewhat nonspecific instead of printing the output of the pcall we can trace it directly to the line by commenting the pcall out.

local timeUntilReset = 10


while wait(1) do
	
	
	timeUntilReset = timeUntilReset - 1
	
	script.Parent.Parent.ResetTime.Text = "Resetting in " .. timeUntilReset .. " seconds..."
	
	
	if timeUntilReset == 0 then
		
		timeUntilReset = 10
	
	
		for i, plr in pairs(game.Players:GetPlayers()) do
			
			coinsODS:SetAsync(plr.UserId, plr.leaderstats.Survivals.Value)
		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, 10)
			local coinsPage = data:GetCurrentPage()
			
			for rankInLB, dataStored in ipairs(coinsPage) do
				
				
				local name = game.Players:GetNameFromUserIdAsync(tonumber(dataStored.key))
				local userid = (tonumber(dataStored.key))
				local coins = dataStored.value
				local thumbType = Enum.ThumbnailType.AvatarBust
				local getthumbnail, isReady = game.Players:GetUserThumbnailAsync(userid, thumbType)
								
				local template = script.Template:Clone()
				
				template.Name = name .. "Leaderboard"
				
				template.PlrName.Text = name
				
				template.Rank.Text = "#" .. rankInLB
				
				template.Coins.Text = coins
				
				template.PlrIcon.Image = getthumbnail
				
				template.Parent = script.Parent				
			end			
		--end)
	end
end

You should get an error this time as well as a line that the error occurred at. Find the line and then send the line that’s throwing the error.

ah so it says Arguement 3 is Missing or nil on this line
local icon, isReady = game.Players:GetUserThumbnailAsync(id, thumbType)

That’s definitely what’s causing it then. This is happening because you didn’t specify an image size. Documented here: Players:GetUserThumbnailAsync


Change your code to this:

local thumbType = Enum.ThumbnailType.AvatarBust
local thumbSize = Enum.ThumbnailSize.Size420x420
local getthumbnail, isReady = Players:GetUserThumbnailAsync(userid, thumbType, thumbSize)

wait my roblox studio crashed but ill test it