Team uniform script, why am I getting a nil error using dictionary?
Asked by
8 years ago Edited 8 years ago
Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.
I'm trying to make a team uniformer script, I've not quite got it. I'll add in comments below.
02 | for i,v in pairs (script.Parent:GetChildren()) do |
09 | function ConfirmTeam(Colour) |
11 | for i,v in ipairs (script:GetChildren()) do |
12 | if v.Value = = Colour then |
19 | for i,v in ipairs (game.Teams:GetTeams()) do |
20 | table.insert(TeamTable, tostring (v.TeamColor).. " Shirt" , ConfirmTeam(v.TeamColor) [ tostring (v.TeamColor).. "Shirt ID" ] - 1 ) |
21 | table.insert(TeamTable, tostring (v.TeamColor).. " Pants" , ConfirmTeam(v.TeamColor) [ tostring (v.TeamColor).. "Pants ID" ] - 1 ) |
24 | for i,v in ipairs (TeamTable) do |
29 | game.Players.PlayerAdded:connect( function (Player) |
30 | Player.CharacterAdded:connect( function (Character) |
31 | Player.AppearanceLoaded:connect( function () |
32 | Player.Shirt.ShirtTemplate = "rbxassetid://" ..TeamTable [ Player.TeamColor ] |
33 | Player.Shirt.PantsTemplate = "rbxassetid://" ..TeamTable [ Player.TeamColor ] |
I get this error:
Workspace.Script:30: attempt to index a nil value
For reference, line 30 begins on line 20 in the question.