Originally Posted by skyraker
I've seen plenty of examples online of how to accomplish it using loadstring, but I've gone through just about every method of using it and cannot get it to work.
|
That's unlikely, because it's not possible. loadstring is always executed in the global scope. You can neither reference local variables nor local functions inside the string of a loadstring() (unless you declare them within the loadstring itself).
i = 0
local i = 5
f = loadstring("i = i + 1")
f()
i = i - 1
The result will be:
i = 1
local i = 4