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.
[URL="http://wiki.garrysmod.com/?title=Local"]For more information.[/URL]
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]
Sorry, you need to Log In to post a reply to this thread.