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

Help with pairs?

Asked by 8 years ago

Basically, this is in a local script. My goal with b[1] was to index the first player in the table, and then take their name and place it as the text of the TextButton. Did I do this right, or is it wrong?

local bench = game.StarterGui.InfoGui.Frame.ABenchP

for x, y in pairs(game.Teams:GetChildren()) do
if y:FindFirstChild("away")
    then
    for a, b in pairs(game.Players:GetChildren()) do
        if b.TeamColor == y.TeamColor then
            if b[1] then bench.a.Text = b.Name
            end
            if b[2] then bench.b.Text = b.Name
            end
            if b[3] then bench.c.Text = b.Name
            end
            if b[4] then bench.d.Text = b.Name
            end
            if b[5] then bench.e.Text = b.Name
            end
            if b[6] then bench.f.Text = b.Name
            end
            if b[7] then bench.g.Text = b.Name
            end
            if b[8] then bench.h.Text = b.Name
            end
            if b[9] then bench.i.Text = b.Name
            end
            if b[10] then bench.j.Text = b.Name
            end
            if b[11] then bench.k.Text = b.Name
            end
            if b[12] then bench.l.Text = b.Name
            end

        end
        end
    end

end

Answer this question