✓ Accepted answer
A local variable makes it, well, local to its scope. A scope is basically its area in the code or its block. For example,
function test()
end
Using a local variable would make the value local to its own block. Another example is,
local test = true;
print(test);
if test then
local test = false;
print(test);
end
print(test);
If you tested that out in studio, then you would notice it prints true, false, then true again. You may also notice that nothing set the value to true again. Inside that if statement is a code block and it locally set the value to false. After the code block has ended, then so has the changes made.
1 comment
Thanks so much! ;-)