How to fix that?

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

So it’s telling you that the variable Name doesn’t have anything set to it (nil).

Is this a script you wrote or did it come from someone else?

Is it only giving this error when testing? Did you test in local or server mode?

Basically, like Scottifly already mentioned, your code is trying to index something which doesn’t exist. Try checking for typos or errors in the path to the requested variable.

i try re-testing the, gui with this script, at other game and this working i dont know. lol…, but other game has more teams. and i try add more teams, its not help.

Follow the path back from where it sets variable Name.
Try adding this line:
print(table.find(activeTeams, team.Name))
before line 43:
if table.find(activeTeams, team.Name) == nil then

1 Like

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