Dan_foodz
Back
Lesson One: Variable, Print/Warn
Hello Players or To-Become Developers!
If you are trying to learn the basics of scripts, I hope this will help you!
Part One, How to make a script in Roblox Studio:
In this part of the Tutorial, I will be showing you how to set up Roblox studio for learning how to code.
First:
Go to https://www.roblox.com/create, and download Roblox Studio.
Next:
Press on "Baseplate", and wait for it to open. This will open up a place for you to make games.
Next:
You need to set up Roblox studio for scripting, but don't worry, it is not hard.
On the top of the screen, you will see a tool bar, find where it says "VIEW".
Next:
When you press on that, below will be a menu of a lot of buttons, make sure that "Explorer", and "Output" is open, if you see anything else open, you do not need to close it, you just need to make sure that "Explorer", and "Output" is open.
(You can tell it is open if it is grayed out)
Next:
We are almost done setting up Roblox Studio, we just need to open a script.
In the explorer (it should be open on your right), you will see a lot of things, they are called services, there are many, but for scripting, you want to go to "ServerScriptService".
Next:
Hover your mouse over "ServerScriptService", and you will see a White "+" Sign pop up, press on the White "+" Sign.
(Please note if you have not pressed on "ServerScriptService", it may be hard to see the white "+" sign, if you can't see the sign, press on "ServerScriptService" and let it turn blue, and you should be able to see the White "+" Sign when you Hover you mouse of "ServerScriptService".)
After you press the White "+" Sign, you will see a menu pop up below "ServerScriptService".
You will see 3 things in the menu, you want to press on "Script".
Part Two, Print/Warn:
This is where the scripting starts!
Happy you have made it to Part Two!
After following Part One, you should see this on your screen:
This is where you script!
Any time you make a script, you will see this code:
print("Hello world!")
What is Print:
Print is very useful in scripting, anything you put between the to parentheses, will be put in the "Output" window, that you opened at the start (It should be at the bottom of the window).
To show this working, go ahead and run the game by pressing "F5" on your keyboard, or press the Play Icon in the tool bar at the top of the screen:
After the game loads, when you look in the "Output", you will see "Hello world!":
Going back to the script (Press "Shift+F5", or the Stop Icon in the tool bar), let's make the Script print something other then "Hello World!"
print("Hello world!")
If you look at the script, you will see that the text that was printed, in in between parentheses, but in the parentheses, they are between double quotation marks ("Hello World!") So, go ahead and edit the text between the 2 double quotation marks to what ever you want, I am going to change mine to "Scripting is cool!"
print("Scripting is cool!")
After editing it, go ahead and run it!
And when you run it, in the output you will see what you put between the 2 double quotation marks, be "printed"!
(Quick Tip: Double quotation marks ("--") **and** Single quotation marks ('--') and both used to tell what is and is not a sting, anything you put between them, will become a string!)
Lets try something new! We have been printing, but now we are going to warn!
What is Warn:
Warn is the same as print, but instead of printing normal text, it prints yellow text as a **warn**-ing.
So how can we do it? It's very simple, just replace "print" with "warn"
warn("Scripting is cool!")
And Run in!
When you look in the output, you will see the warn!
It works the same way as print, but will yellow text!
Part Three, Variables:
How you store values.
I am very happy you made it to Part Three!
Let's talk about Variables!
What are Variables:
In scripting, they are used to store values like Strings, Numbers, and Objects.
How do you make a variable:
You use the word local
, local mean local-variable (a variable that is only used inside of that script)
Format:
local VariableName = "Data"
After the work local, you put a space, then the same a the variable (the variable name must have no spaces, and must begin with a letter), and then you put a space and a equal sign and another space, then you put the data. (String, Number, and so on)
Variable Examples:
local Number = 10
local Name = "John"
local Where = "Work"
local Age = 27
How to use a Variable:
All you need to do is put the Variable name where you want that data, example:
local Text = "Scripting is cool!"
print(Text)
Now try it yourself:
Make a Variable of with you text:
local Text = "Scripting is cool!"
and then print the Variable using the VariableName:
print(Text)
Conclusion!
What you learned, and how you can keep learning!
In this Tutorial, you learned how to Print text with Print()
and Warn()
, and you learned how to make and use variables!
If you want to keep learning, keep trying new things, look stuff up that you want to learn (on Youtube, Devforums, but if you can't find anything there, try google). and keep doing your best, you do not learn scripting in a few days, go slow, take it step by step, and in no time, you will be a great scripter!
If you have any questions or things I could have done differently, contact me:
Discord: Dan_foodz#0751
Guilded: Dan_foodz
Devforums: Dan_foodz
Roblox: Dan_foodz
Have a great day! - Dan_foodz, Developing on Roblox since 2020