Roblox > Scripting Lessons >

Lesson 1: Variables

We will start with the simplest stuff and work our way up. If you ever have any questions about any of these lessons, PM my Roblox account or Post on the Forums.


A variable is basically just a word or short phrase which serves as a sort of container that can store information. For example, you could use the word 'damage' as a variable.

If in your script you wrote:

damage = 1

You would be telling the computer to store the number 1 inside of the variable damage. When the computer executes this piece of code, it stores the number 1 inside of 'damage' so now whenever you use the word damage in your code, the computer will look inside the variable damage and see the number 1. So anywhere in the script that you now use the word damage, the script will act as though you entered the value 1. You can also store words or other objects in variables. For example:

name = "Ajedi32"


brick = script.Parent

Whenever you store a word in a variable, you must be sure to put it in quotation marks: For example if you said this:

name = Ajedi32

The script would look for what is inside the variable named Ajedi32 for a value instead of setting name to the word "Ajedi32"

Simple Right?

Also, remember that variables are case sensitive, and they cannot contain spaces or special characters such as '-'. To make up for the lack of spaces, you can use underscores to separate words in a variable. For example, you could say player_name. Another way to separate words is with capitalization. For example: playerName. Either way of doing this is acceptable, but try to be consistent or in longer scripts you might find yourself having to check if a variable was divided with underscores or with capitalization.

If you have any questions PM me or Post on the Forums and then we will move on.

- Ajedi32

<- Previous Lesson  Next Lesson ->

Updated on Dec 28, 2011 by Ajedi32 (Version 15)
comments powered by Disqus