|
| 12 Nov 2013 04:59 PM |
like local variables.
local x local potato local stufffs
THANKS OBAMA |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 12 Nov 2013 05:08 PM |
When its constrained or open up a new scope, use local.
If you use a variable throughout the script, dont use local. Otherwise, its better to use local.
|
|
|
| Report Abuse |
|
|
|
| 12 Nov 2013 05:11 PM |
Local variables are for a specific function. (If not specified within a function itself, then it's for the whole script and nothing but THAT script.)
Ex. 1 (Used in a function)
function example() local cucumber = Workspace.Part --Now, this may only be used in this function. cucumber.Name = "Cucumber" end
example()
print(cucumber.Name) --This /should/ result in an error.
Ex. 2 (Used in the entire script)
local Apple = "Apple" local Banana = "Banana" -- See? This wasn't specified in a certain function and may be used in this entire script, and can be used in multiple functions. local Fruits = Workspace["Fruits"]
Am I wrong? Feel free to revise me. I'm a little rusty. ;b
~ ∂σи'т нαтє σи тнє ѕιggу ~ |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 12 Nov 2013 05:23 PM |
You're forgetting inside loops, conditional statements...
function potato() local a = 1 while p == 2 do local b = 2 if k == 13 then local c = 3 print(a) print(b) print(c) -- all would run end print(a) print(b) print(c) -- c would error. outside scope end print(a) print(b) print(c) -- b and c would error. outside scope end print(a) print(b) print(c) -- all would error. outside scope |
|
|
| Report Abuse |
|
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
|
| 12 Nov 2013 05:23 PM |
Obama should die.
or get "bloxed" To block the banner people. |
|
|
| Report Abuse |
|
|