Difference between x=y and local x=y

What is the difference between, say, [lua]local x = 70[/lua] and [lua]x = 70[/lua]. I’ve seen both been used and I just tested to see which one works in my scripts (switching them around).

Local variables are limited to the scope where they are defined, inside their block.

For more information.

To add on to what butters said, they’re both valid syntaxes. Here’s a demonstration:

[lua]foo = 5
do – “do end” is just an example for any sort of statement like if, for, while, etc.
local bar = 10
print(foo,bar) – prints 5 and 10
end
print(foo,bar) – prints 5 and nil[/lua]