people tell me i should put local in front of my variables but why
local
variables is deemed to be a better practice because:
for i = 0, 10 do local x = i; end print(x); --nil for i = 1, 100 do local y = i + 100; end print(y); --nil
Even if you really wanted to use global variables, you could simply declare local variables at the beginning of your script....
local x = 0; while x < 10 do x = x + 1; end print(x); -- 10 while x < 100 do x = x + 1; end print(x); -- 100 while x < 50 do x = x + 100; end print(x); -- 100. -- while (100 < 50) is not true. The loop never initiates.
Unless there are specific scenarios where it is an absolute requirement.