I’m sure I’m missing something obvious but I’m getting a string value error in this script.
Players.PlayerAdded:Connect(function(NewPlayer)
local ShortName = FindTeam(tostring(NewPlayer.Team))
local Rand = math.random(1000,9999)
if ShortName then
text.Text = ''ShortName'-'Rand'' <------- Here's the line with the error
end
end)
Not sure what exactly you’re trying to do there.
I’m guessing that you want to combine those values into a single string of text, in which case use 2 dots for concatenation. Example:
Players.PlayerAdded:Connect(function(NewPlayer)
local ShortName = FindTeam(tostring(NewPlayer.Team))
local Rand = math.random(1000,9999)
if ShortName then
text.Text = ''ShortName..'-'..Rand''
end
end)
Players.PlayerAdded:Connect(function(NewPlayer)
local ShortName = FindTeam(tostring(NewPlayer.Team))
local Rand = math.random(1000,9999)
if ShortName then
text.Text = ShortName..'-'..tostring(Rand)
end
end)
This should work if there are any errors it’s because something is not right outside this scope.
What does FindTeam return?
What is this variable “text”?
Players.PlayerAdded:Connect(function(NewPlayer)
local ShortName = FindTeam(tostring(NewPlayer.Team))
local Rand = math.random(1000,9999)
if ShortName then
text.Text = ShortName.."-"..Rand
end
end)
In future, when use speech marks instead of quotation marks (double instead of single) as they’re clearer. Also in Lua the concatenation operator is “…” a pair of two consecutive periods/dots, with their purpose being to join strings together, be it literal strings such as “abc”…“xyz” or variables which store string values such as var1…var2 if you need any further assistance, let me know.