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

Custom player list gives concatenate error?

Asked by 8 years ago
wait()
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
local players = game.Players:GetChildren()
local Beginpos = 10
local Team = {}
local Team2 = {}
local Team3 = {}

function TextLabel(name, text)
    local x = Instance.new('TextLabel', script.Parent)
    x.Name = name
    x.BackgroundColor3 = Color3.new(0/255, 0/255, 0/255)
    x.BackgroundTransparency = 0.5
    x.BorderColor3 = Color3.new(255/255, 164/255, 34/255)
    x.BorderSizePixel = 2
    x.Position = UDim2.new(1, -150, 0, Beginpos)
    x.Size = UDim2.new(0, 140, 0, 20)
    x.Font = 'ArialBold'
    x.FontSize = 'Size14'
    x.Text = '   '..text
    x.TextColor3 = Color3.new(255/255, 255/255, 255/255)
    x.TextStrokeColor3 = Color3.new(0/255, 0/255, 0/255)
    x.TextStrokeTransparency = 0
    x.TextScaled = false
    x.TextWrapped = true
    x.TextXAlignment = 2
end

while wait() do
    for i, v in pairs(script.Parent:GetChildren()) do
        if v.className == 'TextLabel' then
            v:Destroy()
        end
    end
    Team = {}
    Team2 = {}
    Team3 = {}
    for i = 1, #players do
        if players[i].TeamColor == BrickColor.new('Crimson') then
            table.insert(Team, players[i])
        elseif players[i].TeamColor == BrickColor.new('Bright bluish green') then
            table.insert(Team2, players[i])
        elseif players[i].TeamColor == BrickColor.new('Black') then
            table.insert(Team3, players[i])
        end
    end
    TextLabel('Team', 'Team')
    for i = 1, #Team do
        TextLabel('Team', Team[i])
    end
    for i = 1, #script.Parent:GetChildren() do
        if script.Parent:GetChildren()[i].Name == 'Team' then
            script.Parent:GetChildren()[i].Position = UDim2.new(1, -150, 0, Beginpos)
            Beginpos = Beginpos + 30
        end
    end
    TextLabel('Team2', 'Team2')
    for i = 1, #Team2 do
        TextLabel('Team2', Team2[i])
    end
    for i = 1, #script.Parent:GetChildren() do
        if script.Parent:GetChildren()[i].Name == 'Team2' then
            script.Parent:GetChildren()[i].Position = UDim2.new(1, -150, 0, Beginpos)
            Beginpos = Beginpos + 30
        end
    end
    TextLabel('Team3', 'Team3')
    for i = 1, #Team3 do
        TextLabel('Team3', Team3[i])
    end
    for i = 1, #script.Parent:GetChildren() do
        if script.Parent:GetChildren()[i].Name == 'Team3' then
            script.Parent:GetChildren()[i].Position = UDim2.new(1, -150, 0, Beginpos)
            Beginpos = Beginpos + 30
        end
    end
    Beginpos = 10
end

attempt to concatenate local 'text' (a userdata value) -- when I do the for i = 1, #Team2

0
What line did you get the error on? M39a9am3R 3210 — 8y
0
Line 58 for i = 1, #Team2 do PureConcept 0 — 8y
0
Even though it probably is for Lines 48 and 68 the error probably popped up there since it was the team I spawned on PureConcept 0 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

The values of Team2 are players, not strings, fire the TextLabel function with Team2[i].Name instead

Ad

Answer this question