A Roblox Community
Would you like to react to this message? Create an account in a few clicks or log in to continue.

A Roblox Community

A community of Robloxians who want to learn to script and build on Roblox Studio.
 
HomeLatest imagesRegisterLog in
If you're a experienced coder make some tutorials! It would really help the site grow.
Make sure you read the rules(Which can be found by clicking here)
If you're a beginner at coding, try some tutorials.
We have many Moderators/Admins watching this site. Contact them with Questions.
Let us know what your favorite sport is. By clicking here to vote (Click here)
This site is becoming inactive. Lets make it active.
Log in
Username:
Password:
Log in automatically: 
:: I forgot my password
Top posters
blueymaddog
Variables Vote_lcapVariables Voting_barVariables Vote_rcap 
naknak
Variables Vote_lcapVariables Voting_barVariables Vote_rcap 
Supernapalm
Variables Vote_lcapVariables Voting_barVariables Vote_rcap 
m27frogy
Variables Vote_lcapVariables Voting_barVariables Vote_rcap 
slayer9365
Variables Vote_lcapVariables Voting_barVariables Vote_rcap 
myrco919
Variables Vote_lcapVariables Voting_barVariables Vote_rcap 
branefreez
Variables Vote_lcapVariables Voting_barVariables Vote_rcap 
ninga95
Variables Vote_lcapVariables Voting_barVariables Vote_rcap 
CloneTrooper787
Variables Vote_lcapVariables Voting_barVariables Vote_rcap 
raboy117
Variables Vote_lcapVariables Voting_barVariables Vote_rcap 
Top posting users this month
No user
Latest topics
» Where to go from here.
Variables EmptySeptember 14th 2020, 1:20 pm by MrNicNac

» Send me an Email
Variables EmptySeptember 14th 2020, 1:16 pm by MrNicNac

» [v1.6.0.0] Lua Script Obfuscator [No Bytecode]
Variables EmptyJuly 6th 2015, 7:38 pm by m27frogy

» New Site Possibly
Variables EmptyJuly 6th 2015, 4:16 pm by m27frogy

» Ambassador!
Variables EmptyApril 15th 2015, 11:40 pm by naknak

» Boop - Tag
Variables EmptyApril 13th 2015, 9:46 pm by naknak

» Vip Class Script
Variables EmptyApril 13th 2015, 4:54 pm by naknak

» Who's active?!
Variables EmptyApril 13th 2015, 4:52 pm by naknak

» Genesis Point
Variables EmptyJuly 17th 2014, 7:04 pm by branefreez

» Reward System
Variables EmptyJuly 17th 2014, 5:41 am by m27frogy

» Script Request
Variables EmptyJuly 10th 2014, 11:43 am by naknak

» local scripts?
Variables EmptyJuly 10th 2014, 11:39 am by naknak

» Project: Reconstruction [Died]
Variables EmptyJuly 10th 2014, 11:36 am by naknak

» Hi. I am new here
Variables EmptyApril 26th 2014, 4:01 pm by altshiftkey

» What's your favorite sport?
Variables EmptyJanuary 1st 2014, 2:13 pm by m27frogy

» FlashLight Script
Variables EmptyJanuary 1st 2014, 2:11 pm by m27frogy

» Gun Making! [READ DESC]
Variables EmptyJanuary 1st 2014, 2:10 pm by m27frogy

» Hi, I am new here!
Variables EmptyNovember 26th 2013, 3:33 pm by Keanu73

» Improve Coding
Variables EmptyOctober 26th 2013, 1:12 pm by pook03

» Simple Button
Variables EmptySeptember 1st 2013, 6:19 pm by branefreez


 

 Variables

Go down 
4 posters
AuthorMessage
Prodigy
Administrator
Administrator
avatar


Posts : 58
Join date : 2010-07-28

Variables Empty
PostSubject: Variables   Variables EmptyAugust 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 assign 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".
Back to top Go down
http://roblox.forumclan.com
Guest
Guest
avatar



Variables Empty
PostSubject: Re: Variables   Variables EmptyAugust 2nd 2010, 8:28 pm

So yuo can also make it x = game.Workspace.Bluebrick...right?
Back to top Go down
Prodigy
Administrator
Administrator
avatar


Posts : 58
Join date : 2010-07-28

Variables Empty
PostSubject: Re: Variables   Variables EmptyAugust 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.
Back to top Go down
http://roblox.forumclan.com
Guest
Guest
avatar



Variables Empty
PostSubject: Re: Variables   Variables EmptyAugust 2nd 2010, 8:44 pm

ok cool
Back to top Go down
slayer9365
Expert Scripter
Expert Scripter
slayer9365


Posts : 233
Join date : 2010-07-31
Age : 29

Variables Empty
PostSubject: Re: Variables   Variables EmptyAugust 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.
Back to top Go down
Bobbyfishstick5
Expert Scripter
Expert Scripter
Bobbyfishstick5


Posts : 13
Join date : 2010-07-30
Age : 28

Variables Empty
PostSubject: Re: Variables   Variables EmptyAugust 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)
Back to top Go down
Prodigy
Administrator
Administrator
avatar


Posts : 58
Join date : 2010-07-28

Variables Empty
PostSubject: Re: Variables   Variables EmptyAugust 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.
Back to top Go down
http://roblox.forumclan.com
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 26

Variables Empty
PostSubject: Re: Variables   Variables EmptyJanuary 18th 2011, 8:20 am

Nice, simple tutorial! Good job.
Back to top Go down
Sponsored content





Variables Empty
PostSubject: Re: Variables   Variables Empty

Back to top Go down
 
Variables
Back to top 
Page 1 of 1
 Similar topics
-
» Independant Variables

Permissions in this forum:You cannot reply to topics in this forum
A Roblox Community :: Tutorials and Resources :: Beginner-
Jump to: