difference between
local variable =
and
variable =
A local variable is a variable that can only be accessed by other things in the same scope. A variable is made local by adding the keyword local before the variable. It is true that local variables are obtained faster than normal variables. This is because they are integrated into the current environment they were created in.
Something neat about local variables is that they don't seem to really overwrite over a different variable of the same name
Example:
local myPart = Instance.new("Part") myPart.Name = "Part1" myPart.Parent = workspace print(myPart.Name) do --NOTE: This is a 'scope' local myPart = Instance.new("Part") myPart.Name = "Part2" myPart.Parent = workspace print(myPart.Name) end print(myPart.Name)
The source below should shed some more light on that, scopes and stuff.
Source: http://wiki.roblox.com/index.php?title=Variable