Why isn't my localscript adding imagelabels next to a custom leaderboard entry?

I’ve been trying to figure this out for some time now, but with no luck. As I want to change the icon of a custom leaderboard system, the script that I’ve been using isn’t doing what I want it to, and since I’m a beginner scripter, I don’t really know how to fix it… I’ve attempted just going back to my old system, but that won’t do unfortunately. Below you may find the script that I’m using, and hopefully this mistake can be rectified

localscript

localPlayer:GetPropertyChangedSignal("Team"):Connect(function()
	local function iconSwitch(player, teamArray, iconArray)
		for i, value in pairs(TeamArray) do
		if localPlayer.Team.TeamColor.Color == TeamArray[1] then
			print("Testing")
			local Playerlist = player.PlayerGui:WaitForChild("Playerlist")
			local Handler = Playerlist.Frame.Handler
			local Icon = Handler.Template.Icon
			Icon.Image = nil
			if Icon then
				Icon.Image = iconArray[1]
			end

Here are the arrays

local iconImageArray = {
	"rbxassetid://18413761813", 
	"rbxassetid://18413212927", 
	"rbxassetid://18413991987",
	"rbxassetid://18414227286",
	"rbxassetid://18414094164"}
local TeamArray = {
	BrickColor.new("Royal purple"), 
	BrickColor.new("Bright red"), 
	BrickColor.new("Dark green"),
	BrickColor.new("White"),
	BrickColor.new("Electric blue"),
	BrickColor.new("Black"),}

Here’s what its supposed to do
image

Does Testing output to console?

Is the player variable the same as the localPlayer variable?