I’ve been trying to add team icon functionality to this script, and I do believe I’m rather close to being able to do so. However, right now I’m trying to figure out why this module script keeps repeating itself, bombarding me data, as well as lagging the entire game. I have tried adding wait statements on this module script, but to no avail
Below you’ll find the module script that I’m trying to slow down.
--[[
Programmer: Nyxaris
Version: 1.0.3
]]
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
end
end
if player.Team then
local whichTeam = tostring(player.TeamColor)
print(whichTeam)
local teamData = SettingsManager.Team[whichTeam]
header.Icon.Image = teamData.icon
iconSet = true
end
if not iconSet then
local isFriend = IconsManager.IsFriendOfCurrentPlayer(player)
local EF = 17390341
local defaultIcon = ""
local defaultColor = (backgroundColor.R + backgroundColor.G + backgroundColor.B) / 3 > 0.5 and Color3.new(0, 0, 0) or Color3.new(1, 1, 1)
if isFriend then
defaultIcon = "rbxassetid://14724599020"
elseif player:GetRankInGroup(EF) >= 3 then
defaultIcon = "rbxassetid://15533016053"
end
header.Icon.Image = defaultIcon
header.Icon.ImageColor3 = defaultColor
iconSet = true
end
header.Icon.Visible = iconSet
end
end
end
return IconsManager