Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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 .. "]"

1 comment

0

Thanks, man! :D

This discussion is preserved as it was. New answers, comments, and votes are closed.