Variables For New Scripters!

Hello, today I will be making a tutorial on how to script for new scripters. We will start off with one of the easiest parts of scripting. VARIABLES!

Definition

Let’s start with the definition of a variable. A variable is a place where you can store information. Examples: Services, parts, values

How to use a variable
You can simply use local
then the name of the thing you would like it to be known as
Example local DatastoreService = game:GetService("DataStoreService")
Through this example when you would like to call DataStoreService instead of having to do game:GetService("DataStoreService") you can just do DataStoreService as you would call the variable.

Use Cases

You could use it to call a service as shown above

You can also use it to name an object without changing the properties name
You would start with a local
You would then give what you want to name it local Party
(In this example I named it Party)
You would then do what you want to be stored as Party; the variable.
For example, if Party was a Part I would do local Party = game.Workspace.Part
Then instead of have to do game.Workspace.Part every time I wanted to use the part in my script, I could just say Party and it would see that the variable Party is equal to game.Workspace.Part
There are many more use cases not listed
How I use variables

I normally use variables for when I call a service or use an object in my script.

Did you find this useful?
  • Yes
  • No

0 voters

4 Likes