Advertisement
kirda

9

Apr 20th, 2021 (edited)
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.55 KB | None | 0 0
  1. -- Note it's global, making variable global
  2. -- puts it into thing called 'enviroment' which you can
  3. -- access using getfenv, it's performance inefficient
  4. -- so i don't recommend ever doing this
  5. var2 = "Hmm"
  6.  
  7. local playerValue = 2
  8.  
  9. local chosenVar = getfenv(1)["var" .. playerValue]
  10. print(chosenVar)
  11. -- > Hmm
  12.  
  13. -- First argument of getfenv is level of the enviroment
  14. -- 1 and 0 is current enviroment, 2 would be enviroment
  15. -- of function that called this function, 3 would be
  16. -- function that called the function that called this
  17. -- function and so on
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement