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: Quick question.

Previous Thread :: Next Thread 
PhailThoth is not online. PhailThoth
Joined: 01 Apr 2011
Total Posts: 208
24 Dec 2011 11:13 AM
What's the difference between
local part = game.Workspace.Part
and
part = game.Workspace.Part
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
24 Dec 2011 11:19 AM
local variables only last until the end that they're in.

Normal variables last forever.

For example..

function bleh()
local txt = "Hello"
end

print(txt)

>> Error, txt is a nil value.



function bleh()
txt = "Hello"
end

print(txt)

>> Hello
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
24 Dec 2011 11:27 AM
-_-

Dark explained it...
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
24 Dec 2011 11:31 AM
Locals are destroyed when the scope they're in ends. You can make artificial scopes by adding the keyword 'do'.

if true then
local a = 1
do
local b = 2
print("A:", a, "B:", b)
end
print("A:", a, "B:", b)
end


> A: 1 B: 2
> A: 1 B: nil
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
24 Dec 2011 11:34 AM
Once again, dark said that :P
Report Abuse
PhailThoth is not online. PhailThoth
Joined: 01 Apr 2011
Total Posts: 208
24 Dec 2011 03:38 PM
Alright, thanks!
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
24 Dec 2011 03:39 PM
Darkkiller says you're welcome :)
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
24 Dec 2011 03:51 PM
But I added the fact that you can create a new scope whenever you please.


do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do print("Hi") end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
24 Dec 2011 03:54 PM
My script is better.


do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do print("Hi") end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end end

BAM!
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
24 Dec 2011 04:07 PM
Meh

crash__()
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
24 Dec 2011 04:09 PM
Mine wouldn't crash -_-

I'll use a break to stop the loop :)
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
24 Dec 2011 04:11 PM
"Mine wouldn't crash -_-"

Never said it would

"I'll use a break to stop the loop"

What loop? crash__() is a locked function that crashes the game.
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
24 Dec 2011 04:14 PM
"I know mine would never crash :D

I'll say for before do and make it a loop :)

I wasn't talking about crash___() -_-
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