PLEASE KEEP IN MIND THAT DEVELOPING GAMES AND LEARNING TO CODE WILL TAKE TIME AND EFFORT
Hello new or returning developers, I hope you are having an amazing day, in this tutorial you will learn the basics and advanced mechanics of LuaU(Roblox Lua), I am AllabyAiiaby and I will be your guide, so shall we begin?
Setup, Variables & Print()
SETUP
To begin click this link to download Roblox Studio, then run the downloaded file and open roblox studio.
Now click on the new tab (opened by default) on the left hand sidebar and click on Baseplate or Old Baseplate.
Once you have opened up Baseplate and it has loaded on the top of your screen click on the words ‘View’ and then make sure you select all these options below:
- Properties
- Explorer
- Output
and then put your mouse to the sides of these boxes and drag them to be as small as possible to not obstruct your view as much, well done!
We now have a brand new project ready to configure, lets move on!
VARIABLES AND PRINTING
Now in our explorer (most likely on the right of your screen) look for the text ‘ServerScriptService’ hover over it and then click the + icon and search ‘Script’ add a new Script, make sure not to add a local or module script!
First to begin with understanding the studio let’s talk about services:
-
Workspace
The workspace is everything that the player can view (without exploiting) and is where most of your builds and non-scripting related objects will be! -
Players
This will (when you start your game) be where your player’s information and object will be, this is where you can edit anything about the player. -
Lighting
We will not be mentioning this in this tutorial! -
Replicated First
We will not be mentioning this in this tutorial! -
Replicated Storage
Replicated Storage is one of the only services that allows both the client (player) and server (game) to communicate between each other, this is where most of your communication with the client will take place using events. -
ServerScriptService
This is where most if not all of your server scripts will be located, the client will not be able to access any scripts located here meaning that hackers cannot edit scripts here, which is essential to your games protections. -
ServerStorage
This service cannot be accessed by the client so keep all your important items that you will introduce into the game later in here, such as a overhead UI (User Interface) -
StarterGui
This is where all your pre-game GUI will be managed and configured, on game start this will replicated into PlayerGui (We will talk about this in more detail later). -
StarterPack
Any items/tools put in here will be put in the players toolbar/hotbar on game start. -
Teams
Teams is where all your teams will be managed. -
StarterPlayer
This is where all you character and GUI scripts are recommended to be located in. -
Other Services that will not be mentioned in this tutorial
Right, so now we know the services of Roblox, now double click your script in roblox and you should be granted by this:
print("Hello World!")
Now if you go to your ‘Home’ tab and press the arrow below play/run and click on play, and in your output (most likely located on the bottom of your screen) you should see:
Hello world! - Server - Script:1
then click stop to return to your editing.
Now we know the basics of scripts and services lets look at variables and print().
A variable or var is a type of storage method that can be chaned and used later on, let’s say sahara has 5 cups and 2 juice bottles, we need to create a var to hold these values, to create a var type local var_name = var_value
in our case we need to create 2 variables with 2 different values so lets do that like this:
local cups = 5
local bottles = 2
(Keep in mind you can not create a variable name with spaces either use camelCase or underScores_)
We use local to define that this variable is only going to be used inside this script (We will talk about global variables later) and then insert our variable name we use = to then assign a value and then type our value, if you want to know more about operators(±=) then go to this page, now we want to tell our guests how much we have so we use this code:
print('We have '.. cups ..' cups and '.. bottles ..' bottles')
Running the game will give you:
We have 5 cups and 2 bottles - Server
Notice how we use two periods(.) this conjoins values, and why didn’t we put our var’s in ‘’ or “”, well because if we use “” or ‘’ we are telling the program that we are printing or defining a string, and a variable should never be printed or used in anything other than defining it using ‘’ or “” else our output would have been We have cups cups and bottles bottles
Here are the variable types:
-
String
A string is text and defined in-between ‘’ or “” and is defined as such
local variable = ‘Hello World!’ -
Interger
This is a number value and is defined as such:
local variable = 0 -
Boolean
A true of false value, defined as such:
local variable = true (or) local variable = false
Well done you have completed section one!
The seconds part of this tutorial will be released later on today, make sure to keep updated on new updates within this tutorial!
NEW UPDATE : BST 22/05/2022 15:10
Hey, check out the complete revamp of this tutorial, I really hope all begineer and returner developers enjoy this public resource and any community feedback will be considered and added, thank you Robloxia for your great help to my journey, now it’s my turn to give back to you.
UPDATE : 10:50 24/05/2022 BST
This project will not be updated until I have completed my current work which will be released soon as of this announcement!