how to fix that?
Error :
22:18:40.115 Players.SerBogdan03.PlayerGui.CustomPlayerList.Scripts.Server.teamModule:43: attempt to index nil with 'Name' - Server - teamModule:43
Script:
local teamStuff = {}
local activeTeams : {} = {}
local order : number = -2
local settingsMoudle = require(script.Parent.Parent.SETTINGS)
local clientPlayerModule = require(script.Parent.Parent.Client.playerActions)
local mainFrame : ScrollingFrame = script:FindFirstAncestorWhichIsA("ScreenGui").Main
local setupFrame : RemoteEvent = script.Parent.Parent.Parent.Events.setupFrame
local scriptPlr : Player = script:FindFirstAncestorWhichIsA("Player")
-- Orders players based off of badges, the lower the number, the higher the position on the list
local function orderPlayer(player : Player)
local badges = clientPlayerModule.getBadges(player)
if table.find(badges, "Admin") then
return 1
elseif table.find(badges, "Friend") then
return 2
elseif table.find(badges, "Premium") then
return 3
else
return 4
end
end
function teamStuff.cleanUpTeams()
-- Loops through every Team
for _, child in ipairs(game.Teams:GetChildren()) do
-- Checks if Team is on mainFrame
if table.find(activeTeams, child.Name) ~= nil then
-- Sees if team has no players
if #child:GetPlayers() == 0 then
-- Removes team from mainFrame if it does not have anymore players
table.remove(activeTeams, table.find(activeTeams, child.Name))
mainFrame[child.Name]:Destroy()
end
end
end
end
function teamStuff.manageTeams(player : Player, team : Team, playerTable : {})
-- Checks if player's team is on PlayerList
if table.find(activeTeams, team.Name) == nil then
-- If player's team is not on PlayerList (puts players team on list)
table.insert(activeTeams, team.Name)
local TeamFrame = mainFrame.Parent.Clones.Team:Clone()
TeamFrame.Parent = mainFrame
TeamFrame.Name = team.Name
setupFrame:FireClient(scriptPlr, TeamFrame, team.Name)
-- Checks if team is prioritized
local pOrder = table.find(settingsMoudle.teamBias, team.Name)
if pOrder then
-- Team is prioritized
local pTeams : number = 0
local NoNpTeams : {} = {}
for _,v in ipairs(activeTeams) do
if table.find(settingsMoudle.teamBias, v) then
-- Is prioritized
mainFrame[v].BackgroundColor3 = game.Teams[v].TeamColor.Color
mainFrame[v].LayoutOrder = pTeams * 5
pTeams += 1
else
-- Is not prioritized
table.insert(NoNpTeams, v)
end
end
-- Loops through all teams that were not prioritized
for _,v in ipairs(NoNpTeams) do
mainFrame[v].LayoutOrder = pTeams * 5
for _, vPlayer : Player in ipairs(playerTable) do
mainFrame[v].BackgroundColor3 = game.Teams[v].TeamColor.Color
mainFrame[vPlayer].LayoutOrder = pTeams * 5 + orderPlayer(player)
end
pTeams += 1
end
order = pTeams * 5
else
-- Team is not prioritized
TeamFrame.BackgroundColor3 = game.Teams[team.Name].TeamColor.Color
TeamFrame.LayoutOrder = order + 5
order = order + 5
end
end
end
return teamStuff