✓ Accepted answer
local variables are in a scope, when they're put at the top of a script they can be used for everything in the script because everything is in their scope. However, if you put a local variable inside of a function, you can only use it inside of that function, if you don't make it local, it can be accessed outside of the function, because it's global. You can also set a variable later by making it local.
local var
var = "hello"
function pr()
local var = "Hello"
end
print(var) ->nil
function pr()
var = "Hello"
end
print(var) ->Hello