So, I'm wondering if it's possible some how to create different variables each time a for loop runs. What I have is an array whose values are tables, listed in a certain order. What I'm trying to do is run through the array, and assign each table to a respective variable.
I know about using multiple assignment, however I don't know how many tables will be in the array when I need to create the variables. The other problem arises when creating the variable name, as (to my knowledge) variables cannot have concatenation in them, or any special operators. Thus I cannot make individual variables whose names correspond with their respectable value, or table in the array.
for i, v in pairs(PlayerScores)do
player..i = PlayerScores[v] -- The variable 'player..i' would be player1 for table 1 in the array, and player2 for table 2, and so on.
end
Is there any way to do this? I can't create the variables individually, as the amount of tables(amount of players), may be fewer than variables I'm assigning. So I'd error out.
Any help is appreciated, and if anything needs clarification please let me know. Thanks! :)

1 comment
Would you be able to store them in a table e.g. [player..i] = PlayerScores[v] or have i got the wrong idea lol