I’m currently in the process of using an array for the first time, however, as I’m using it, it gets to a certain point and then spits out this error. I’ve tried reorganizing the teams a little, but that seemingly didn’t work out. It is also my first time messing around with pairs.
The localscript responsible
local teamTable = {
["Lime green"] = "rbxassetid://18413212927",
["Dark blue"] = "rbxassetid://18414094164",
["Maroon"] = "rbxassetid://18414227286"
}
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
for i, team in pairs(Teams:GetChildren()) do
_teams [team.Name] = i
end
for i, value in pairs(teamTable) do
if localPlayer:GetPropertyChangedSignal("Team") then
if localPlayer.Team.Name == i then
Icon.Image = value
Icon.Active = true
end
end
end
it doesn’t throw the error anymore, but I’m still facing another bug. Upon team switch, it doesn’t show the icon. In fact, it remains inactive within the playergui…
local function refresh()
for _, obj in pairs(Frame:GetChildren()) do
if obj:IsA("TextLabel") then
obj:Destroy()
if obj:IsA("ImageLabel") then
obj:Destroy()
end
end
end
for _, player in pairs(Players:GetPlayers()) do
local Text = Template:Clone()
Text.Parent = Frame
Text.Text = player.Name
if player.Team then
Text.TextColor3 = player.TeamColor.Color
Text.LayoutOrder = _teams[player.Team.Name]
else
Text.LayoutOrder = #Teams:GetChildren() + 1
end
end
end
That PlayerAdded doesn’t fire for you since your LocalScripts are executed once you join.
But yes, the rest is fine, you can just pass the function in Connect instead of creating anonymous function that calls the refresh function