Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Note it's global, making variable global
- -- puts it into thing called 'enviroment' which you can
- -- access using getfenv, it's performance inefficient
- -- so i don't recommend ever doing this
- var2 = "Hmm"
- local playerValue = 2
- local chosenVar = getfenv(1)["var" .. playerValue]
- print(chosenVar)
- -- > Hmm
- -- First argument of getfenv is level of the enviroment
- -- 1 and 0 is current enviroment, 2 would be enviroment
- -- of function that called this function, 3 would be
- -- function that called the function that called this
- -- function and so on
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement