Help with ground progress bar / player images

Hello, so I had some help making a ground progress bar before, but Ive come across an error that I do not know how to fix.
image
Basically all the players are there on the bar, but their avatars do not load. Instead it loads the player that has been alive the longest(?)
Code:

local startPosition = game.Workspace.Arrow.CFrame.Position
local totalDist = (EndPosition - startPosition).Magnitude

-- Assuming all connected players are being calculated

local function ClearChildren()
	for i,v in pairs(script.Parent:GetChildren()) do
		if v:IsA("LocalScript") then continue end
		v:Destroy()
	end
end

game:GetService("RunService").RenderStepped:Connect(function()
	ClearChildren()
	local players = game.Players:GetPlayers()
	for _,player in pairs(players) do
		local char = player.Character
		local humanoidRootPart = char:FindFirstChild("HumanoidRootPart")

		if humanoidRootPart then
			for _, player in ipairs(players) do
				local playerImage = Instance.new("ImageLabel")
				playerImage.Name = player.Name .. "-Image" 
				playerImage.Parent = script.Parent
				playerImage.BackgroundTransparency = 1


				local dist = (EndPosition - humanoidRootPart.Position).Magnitude
				local playerImageContent, isReadyToBeUsed = game.Players:GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)

				--local playerImage = script.Parent.PlayerImage


				if isReadyToBeUsed then
					playerImage.Image = playerImageContent
				end

				local perc = 1 - (dist / totalDist)
				playerImage.Position = UDim2.fromScale(perc, 0)
				playerImage.Size = UDim2.fromScale(0.1,1)
			end
		end
	end 
end)```

You should consider giving a depth description.

First thing I’d change is the second for loop. You’re using the same variables as the first one, which might cause some issue?

Shouldn’t that nested for loop be a single loop? You’re currently iterating over each player while iterating over each player.

for _, player in ipairs(players) do
	local character = player.Character
	if character then
		local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
		if humanoidRootPart then
			local playerImage = Instance.new("ImageLabel")
			playerImage.Name = player.Name .. "-Image" 
			playerImage.Parent = script.Parent
			playerImage.BackgroundTransparency = 1


			local dist = (EndPosition - humanoidRootPart.Position).Magnitude
			local playerImageContent, isReadyToBeUsed = game.Players:GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)

			--local playerImage = script.Parent.PlayerImage


			if isReadyToBeUsed then
				playerImage.Image = playerImageContent
			end

			local perc = 1 - (dist / totalDist)
			playerImage.Position = UDim2.fromScale(perc, 0)
			playerImage.Size = UDim2.fromScale(0.1,1)
		end
	end
end

You may need to debug this further, I just merged the two loops into a single one.

Thank you so much, this worked!