Hello! I am trying to figure out how to set a string value to be equal to a predefined local variable. Below is an example of what I am trying to accomplish:
local var2 = "Hmm"
local playerValue = 2
local chosenVar = "var"..playerValue --This would ideally be equal to the local variable on line 1.
print(chosenVar) --Instead, it just prints "var2" because it is just a string.
Instead of it printing var2, how could I make it print the local variable of var2 which is "Hmm"

3 comments
Good solution, however, it's still possible to do exactly what Bunny wants, not saying it's good practice or anything but using getfenv and globals it works : https://pastebin.com/MbiHUFbM
Thank you for the answers! I appreciate you both for taking time out of your days to help!
I wasn't aware of that, I knew lua scripts had some sort of global directory and I thought about it when I made the post, but I brushed it off. I will edit my post, thanks :)