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

attempt to concatenate field '?' (a table value) error?

Asked by
iRexBot 147
7 years ago
Edited 7 years ago

So I have this error where it would say "Workspace.danzflor.MidDanceFloor.CoreDancefloor:453: attempt to concatenate field '?' (a table value)" I cannot fix it as hard as I try it won't work can anyone else possibly fix it for me? Thanks on advanced!

local LetterTable = { [1] = {"A"},
[2] = {"B"},
[3] = {"C"},
[4] = {"D"},
[5] = {"E"},
[6] = {"F"},
[7] = {"G"},
[8] = {"H"},
[9] = {"I"},
[10] = {"J"},
}


local chosenPad = LetterTable[math.random(1,#LetterTable)]..math.random(1, 10)
print(chosenPad)

1 answer

Log in to vote
1
Answered by
luadotorg 194
7 years ago

Hey.

This is because you are using the [X] = Y syntax.

For the code you are trying to do, [X] = Y is useless, as it has another job in tables than what you are trying to do.

There is a simple solution:

local LetterTable = { "A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
}


local chosenPad = LetterTable[math.random(1,#LetterTable)]..math.random(1, 10)
print(chosenPad)

Hope this helps you!

Ad

Answer this question