I'm currently editing a module. What would I add in order to implement team icon support?

I’ve been editing this module Custom PlayerList [Supports: Teams/Leaderstats/Group Icons/Custom team order] - #59 by BuchstabensalatTC

I wish to implement within team icon support, and so far I’ve gotten kinda close, but at each opportunity it fails, as in not printing the correct information. Below, you will see my attempts versus actual successful icon implementation. I hope through this I’ll be able to get some help in doing so.

Icon Manager Module (I’m the one trying to add team data)

function IconsManager.UpdatePlayerIcon()
	for _, player in pairs(game.Players:GetPlayers()) do
		local playerFrame = PlayerList:FindFirstChild(player.Name .. "_Frame")
		if playerFrame then
			local iconSet = false
			local header = playerFrame.PlayerHeader
			local backgroundColor = header.BackgroundColor3

			if SettingsManager.Settings.groupRanks.enableGroupRanks and SettingsManager.Settings.groupRanks.groupID then
				local rankInGroup = player:GetRankInGroup(SettingsManager.Settings.groupRanks.groupID)
				local rankData = SettingsManager.GroupRanks[rankInGroup]
				if rankInGroup and rankData then
					header.Icon.Image = rankData.icon
					iconSet = true
				end
			end
			
			if player.Team then
				local whichTeam = player.TeamColor ==
				print(whichTeam)
				local teamData = SettingsManager.Team[whichTeam]
				if teamData then
					print(teamData)
					header.Icon.Image = teamData.icon
					header.Icon.ImageColor3 = teamData.color
					iconSet = true
				end
			end

Here is the SettingsManager script that this line of code is referencing

local SettingsManager = {}

--// Main Settings
SettingsManager.Settings = {
	groupRanks = {
		groupID = nil,
		enableGroupRanks = false
	},
	leaderstats = {
		folderName = "leaderstats",
		enable = false
	},
	teams = {
		DisplayingAllTeams = false, --[[If 'false' is specified, then players will see in the PlayerList only those teams that have players. 
		If 'true' is specified, the players will see a list of all the teams in the game, even those with no players]]
		CustomLayoutOrder = false --[[If you want to specify your command order, set this function to 'true' and fill in the list of commands 'CustomLayoutOrder'. 
		We recommend enabling the 'DisplayingAllTeams' function to make look better custom layout order]]
	}
}

--// Group ranks
SettingsManager.GroupRanks = {
	[5] = {
		icon = "rbxassetid://0"
	},
	[20] = {
		icon = "rbxassetid://0"
	},
	[255] = {
		icon = "rbxassetid://0"
	}
}

SettingsManager.Team = {
	["Royal purple"] = {
		icon = "rbxassetid://18413761813"
	},
	["Bright red"] = {
		icon = "rbxassetid://18413212927"
	},
	["Dark green"] = {
		icon = "rbxassetid://18413991987"
	},
	["White"] = {
		icon = "rbxassetid://18414227286"
	},
	["Electric blue"] = {
		icon = "rbxassetid://18414094164"
	}
	
}
1 Like

I’m pretty much trying to receive a guideline of how I’d go about adding team icon support through this module. Since I’m obviously doing things wrong, and would like to know how I can successfully add this feature that I wish to add.

local IconsManager = {}

--// Dependencies
local Modules = script.Parent
local ServiceManager = require(Modules.ServiceManager)
local SettingsManager = require(Modules.SettingsManager)

--// UI Elements
local Players = ServiceManager.Players
local PlayerList = ServiceManager.PlayerList

--// Functions
function IconsManager.IsFriendOfCurrentPlayer(player)
	local currentPlayer = Players.LocalPlayer
	if currentPlayer and currentPlayer ~= player then
		return currentPlayer:IsFriendsWith(player.UserId)
	end
	return false
end

function IconsManager.UpdatePlayerIcon()
	for _, player in pairs(game.Players:GetPlayers()) do
		local playerFrame = PlayerList:FindFirstChild(player.Name .. "_Frame")
		if playerFrame then
			local iconSet = false
			local header = playerFrame.PlayerHeader
			local backgroundColor = header.BackgroundColor3

			if SettingsManager.Settings.groupRanks.enableGroupRanks and SettingsManager.Settings.groupRanks.groupID then
				local rankInGroup = player:GetRankInGroup(SettingsManager.Settings.groupRanks.groupID)
				local rankData = SettingsManager.GroupRanks[rankInGroup]
				if rankInGroup and rankData then
					header.Icon.Image = rankData.icon
					iconSet = true 
				if player.TeamColor == "Royal purple" then
						header.Icon.Image = "rbxassetid://18413761813"
				end
				
					if player.TeamColor == "Bright red" then
						header.Icon.Image = "rbxassetid://18413212927"
					end
					
					if player.TeamColor == "Dark green" then
						header.Icon.Image = "rbxassetid://18413991987"
					end
					
					if player.TeamColor == "White" then
						header.Icon.Image = "rbxassetid://18414227286"
					end
					
					if player.TeamColor == "Electric blue" then
						header.Icon.Image = "rbxassetid://18414094164"
					end
	            
				end
			end
		end
	end
end

return IconsManager

Here the script. It really is basic and I hope it works. If it doesn’t work for you, send me a file with the complete GUI and I’ll see what I can solve. You can disable the “SettingsManager” or leave it as default.

Oh, I have already implemented this, thanks for the reply though!

With great pleasure. Let me know if it worked.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.