With Lua a variable can be defined anywhere on the fly but unless you specify it as local it will be added to the global name table, the bigger that gets the slower it is to access. Also Lua cannot free up variable storage if it global because it doesn't know what you have finished with (unless you specifically set it to nil), local variables can be freed up at the end of the function by the garbage collection.
Defining local variables outside of functions doesn't really do anything much, they will still be added to the global name table but access to them may be restricted, it depends on how Lee has set up the environment.
The best use of local variables is to hold virtual pointers into global lists , the "Soldier" variable in the other script is an example of that, not only is it more readable but it is far more efficient that accessing the global list directly. At first glance you may think it is making a copy of the contents of the list but that isn't how Lua operates, it is actually pointing directly at the entry in the list so you could for example say Soldier.health = 50 and that would update the global list. Takes a bit of getting used to I'll admit.
Been there, done that, got all the T-Shirts!