Hello Developers!
If you are trying to learn the basics of scripts, I hope this will help you!
NOTE: If you don’t know how to do the basics of Roblox Studio, you will not be able to do this tutorial, but you can learn that in my lesson: The Basics of Roblox Studio
Part One, How to Open a Script:
First:
Hover your mouse over “ServerScriptService”, and you will see a White “+” Sign pop up, press on the White “+” Sign.
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 will program!
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 two parentheses, will be put in the “Output” 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, post then below, or contact be:
Discord: Dan_foodz#0751
Devforums: Dan_foodz
Roblox: Dan_foodz
Have a great day! - Dan_foodz, Developing on Roblox since 2020