Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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.

01function RenameTeams() -- This function renames all the teams, as the user-friendly system lets them simply copy the template.
02    for i,v in pairs(script.Parent:GetChildren()) do
03        v.Name = "Team "..i
04    end
05end
06 
07TeamTable = {} -- Where I store teams and uniforms as a dictionary, e.g ["White Shirt"] = 103021030
08 
09function ConfirmTeam(Colour) -- Used to return a colour to the next loop
10    local Found = nil
11    for i,v in ipairs(script:GetChildren()) do
12        if v.Value == Colour then
13            Found = v
14        end
15    end
View all 36 lines...

I get this error:

Workspace.Script:30: attempt to index a nil value

For reference, line 30 begins on line 20 in the question.

0
I am very confused what you are *trying* to accomplish on line 20, because that is not how you use table.insert. BlueTaslem 18071 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

table.insert shouldn't be like how it is on line 20.

Ad

Answer this question