Top posting users this month | |
Latest topics | » Where to go from here.September 14th 2020, 1:20 pm by MrNicNac» Send me an EmailSeptember 14th 2020, 1:16 pm by MrNicNac» [v1.6.0.0] Lua Script Obfuscator [No Bytecode]July 6th 2015, 7:38 pm by m27frogy» New Site PossiblyJuly 6th 2015, 4:16 pm by m27frogy» Ambassador!April 15th 2015, 11:40 pm by naknak» Boop - TagApril 13th 2015, 9:46 pm by naknak» Vip Class ScriptApril 13th 2015, 4:54 pm by naknak» Who's active?!April 13th 2015, 4:52 pm by naknak» Genesis PointJuly 17th 2014, 7:04 pm by branefreez» Reward SystemJuly 17th 2014, 5:41 am by m27frogy» Script RequestJuly 10th 2014, 11:43 am by naknak» local scripts?July 10th 2014, 11:39 am by naknak» Project: Reconstruction [Died]July 10th 2014, 11:36 am by naknak» Hi. I am new hereApril 26th 2014, 4:01 pm by altshiftkey» What's your favorite sport?January 1st 2014, 2:13 pm by m27frogy» FlashLight ScriptJanuary 1st 2014, 2:11 pm by m27frogy» Gun Making! [READ DESC]January 1st 2014, 2:10 pm by m27frogy» Hi, I am new here!November 26th 2013, 3:33 pm by Keanu73» Improve CodingOctober 26th 2013, 1:12 pm by pook03» Simple ButtonSeptember 1st 2013, 6:19 pm by branefreez |
|
| Variables | |
| | Author | Message |
---|
Prodigy Administrator
Posts : 58 Join date : 2010-07-28
| Subject: Variables August 2nd 2010, 8:15 pm | |
| Variables and functions are used to help you shorten your code and create easy shortcuts to executing scripts. Variables: A variable is a name, given by a programmer, to represent a piece of data. This name is then used to refer to that piece of data at any time in the script. Example Bob wants to change the color of a brick multiple times. His code is as follows. - Code:
-
game.Workspace.Bluebrick.BrickColor = BrickColor.new("Cyan") wait(5) game.Workspace.Bluebrick.BrickColor = BrickColor.new("Really Red") wait(5) game.Workspace.Bluebrick.BrickColor = BrickColor.new("Black") wait(5) game.Workspace.Bluebrick.BrickColor = BrickColor.new("White") Bob is tired of writing " game.Workspace.Bluebrick.BrickColor" over and over. He wants a way to shorten the code. Bob could as sign a variable to " game.Workspace.Bluebrick.BrickColor" so that he doesn't need to write that part of the code again and again. Bob's code shortened by a variable would look like the following - Code:
-
Myfirstvar = game.Workspace.Bluebrick Myfirstvar.BrickColor = BrickColor.new("Cyan") wait(5) Myfirstvar.BrickColor = BrickColor.new("Really Red") wait(5) Myfirstvar.BrickColor = BrickColor.new("Black") wait(5) Myfirstvar.BrickColor = BrickColor.new("White") The " Myfirstvar = game.Workspace.Bluebrick" part of the code sets the variable. The Variables are CASE SENSATIVE, meaning, if your variable was "Hello" you could not write "hello" or "HELLO". | |
| | | Guest Guest
| Subject: Re: Variables August 2nd 2010, 8:28 pm | |
| So yuo can also make it x = game.Workspace.Bluebrick...right? |
| | | Prodigy Administrator
Posts : 58 Join date : 2010-07-28
| Subject: Re: Variables August 2nd 2010, 8:32 pm | |
| - Filthynate wrote:
- So yuo can also make it x = game.Workspace.Bluebrick...right?
Yes. You can put anything you want there. | |
| | | Guest Guest
| Subject: Re: Variables August 2nd 2010, 8:44 pm | |
| |
| | | slayer9365 Expert Scripter
Posts : 233 Join date : 2010-07-31 Age : 29
| Subject: Re: Variables August 3rd 2010, 2:23 pm | |
| Please note that if you save a Value, when reading the Value, it will come up with the original value that was there when you created the variable. | |
| | | Bobbyfishstick5 Expert Scripter
Posts : 13 Join date : 2010-07-30 Age : 28
| Subject: Re: Variables August 3rd 2010, 2:45 pm | |
| You can set mutiple variables in a single line also. Like this
local (a, b, c = c, b a) print(a, b, c) | |
| | | Prodigy Administrator
Posts : 58 Join date : 2010-07-28
| Subject: Re: Variables August 3rd 2010, 5:59 pm | |
| - Bobbyfishstick5 wrote:
- You can set mutiple variables in a single line also. Like this
local (a, b, c = c, b a) print(a, b, c) That's more advanced though. This is just a beginner tutorial. | |
| | | blueymaddog Administrator
Posts : 1081 Join date : 2010-12-09 Age : 26
| Subject: Re: Variables January 18th 2011, 8:20 am | |
| Nice, simple tutorial! Good job. | |
| | | Sponsored content
| Subject: Re: Variables | |
| |
| | | | Variables | |
|
Similar topics | |
|
| Permissions in this forum: | You cannot reply to topics in this forum
| |
| |
| Who is online? | In total there are 3 users online :: 0 Registered, 0 Hidden and 3 Guests
None
Most users ever online was 136 on October 21st 2024, 12:16 pm
|
| Please tell us what time zone you are in here
Got a really good idea? Post it in projects and it might show up here! |
|