I'm trying to make a team uniformer script, I've not quite got it. I'll add in comments below.
function RenameTeams() -- This function renames all the teams, as the user-friendly system lets them simply copy the template. for i,v in pairs(script.Parent:GetChildren()) do v.Name = "Team "..i end end TeamTable = {} -- Where I store teams and uniforms as a dictionary, e.g ["White Shirt"] = 103021030 function ConfirmTeam(Colour) -- Used to return a colour to the next loop local Found = nil for i,v in ipairs(script:GetChildren()) do if v.Value == Colour then Found = v end end return Found end for i,v in ipairs(game.Teams:GetTeams()) do -- This function indexes all the teams' uniforms and their colour. table.insert(TeamTable, tostring(v.TeamColor).." Shirt", ConfirmTeam(v.TeamColor)[tostring(v.TeamColor).."Shirt ID"] - 1) table.insert(TeamTable, tostring(v.TeamColor).." Pants", ConfirmTeam(v.TeamColor)[tostring(v.TeamColor).."Pants ID"] - 1) end for i,v in ipairs(TeamTable) do print(v) end game.Players.PlayerAdded:connect(function (Player) Player.CharacterAdded:connect(function (Character) Player.AppearanceLoaded:connect(function () Player.Shirt.ShirtTemplate = "rbxassetid://"..TeamTable[Player.TeamColor] Player.Shirt.PantsTemplate = "rbxassetid://"..TeamTable[Player.TeamColor] -- Here, we search the colour from the table and find the uniform, then add it. end) end) end)
I get this error:
Workspace.Script:30: attempt to index a nil value
For reference, line 30 begins on line 20 in the question.