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

I get the error attempt to concatenate field 'Team' (a userdata value). What am I doing wrong?

Asked by 6 years ago

I am working on a game where I have a custom playerlist with team support. However, I get this error that I don't understand. I do know it is an error when you forget to mention the ".Value" in a variable object. But this? Hmm...

Error:

17:24:16.069 - Players.iBoai.PlayerGui.CustomPlayerlist.MainFrame.PlayerListManager:12: attempt to concatenate field 'Team' (a userdata value)

Code:

wait(2)
local teams = game:GetService("Teams")
local teamLobby = teams:WaitForChild("Lobby")
local teamKiller = teams:WaitForChild("Killer")
local teamTestSubjects = teams:WaitForChild("Test Subjects")
local labelModel = script.Parent.Model
local lastSize = script.Parent.LastSize

while script.Parent.Visible == true and wait(0.1) do
    for i,v in pairs(game.Players:GetChildren()) do
        local newLabel = labelModel:Clone()
        newLabel.Text = "["..v.Team.."] "..v.Name
        newLabel.Position = UDim2.new(1, 1, 0, lastSize.Value)
        newLabel.Visible = true
        lastSize.Value = lastSize.Value + 50
    end
end

What the heck am I doing wrong? Hmm...

1 answer

Log in to vote
1
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago

Since the team is an Object, when you try to concatenate it using .. it errors. To fix this, all you should need to do is get the team's Name, which is a string.

"[" .. v.Team.Name .. "]"
0
Thanks, man! :D User#21527 0 — 6y
Ad

Answer this question