generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: When do you say 'local' in a script?

Previous Thread :: Next Thread 
2tallhank is not online. 2tallhank
Joined: 11 Jun 2010
Total Posts: 2075
28 Feb 2012 07:11 PM
[ Content Deleted ]
Report Abuse
swmaniac is not online. swmaniac
Joined: 28 Jun 2008
Total Posts: 15773
28 Feb 2012 07:19 PM
When you define a variable as "local" to the block of code (everything between the function/do/repeat to until/end)

The variable does not exist outside that block of code - this is called the variable's "Scope."
Report Abuse
2tallhank is not online. 2tallhank
Joined: 11 Jun 2010
Total Posts: 2075
28 Feb 2012 07:21 PM
[ Content Deleted ]
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
28 Feb 2012 07:23 PM
"to the block of code (everything between the function/do/repeat to until/end)"

The scope.

"Bro five! Wear this to let everyone know you think they deserve a high five."
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
28 Feb 2012 07:26 PM
Making a variable local will only be accessible in the scope it's declared in or any higher scope.

    --Scope

    while (true) do
        --Scope2
        local a=1
        b=2
        print(a,b)
    end
    print(a,b)

"Bro five! Wear this to let everyone know you think they deserve a high five."
Report Abuse
swmaniac is not online. swmaniac
Joined: 28 Jun 2008
Total Posts: 15773
28 Feb 2012 07:32 PM
@nate

I also explained that the block of code in which a local variable is declared is the variable's scope. ._.

A block of code is all code between any given function/if/do/repeat and the end/until that closes it.
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
28 Feb 2012 07:36 PM
I'll write a better example, because my last example and statement or both slightly incorrect and vague.

"Bro five! Wear this to let everyone know you think they deserve a high five."
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image