Beginner Scripting Tutorial - Beginner Guide!

Hello DevForum!
This post is mostly for beginners who are struggling to learn how to script (Or if you know only a little bit of knowledge)!

(Oh yes by the way just ignore the scripts at the top)

Windows and theme color

Ever see people with this screen but you don’t have it?

But instead you have this (probably)

Well no worries friend! I’ll show you how to get them.

First, Find the top bar and find “VIEW”
Now this should appear on the bar!

(Bad screenshot I know)
Now you need to press on Output (Actually optional), Script Analysis (Also optional) and- wait that’s pretty much it.

Ah also, wondering why the Output window is optional? (Because you probably see a lot of videos with the Output window open) It’s because there is a thing called a console! But we will talk about that more later.

Now you this part is option, you need to go to MODEL. How to do that? Same thing as the VIEW tab! Now you need to find Insert Object. It’s all the way to the right!

Alright, this part is optional too, but it is recommended!

What you need to do it press-

Windows
Alt+S

Macbook
Option+S

-then this will appear!

Now, in your search bar type in “theme”. Now click on the first option twice (or once) and press dark theme! Wow, so much better!

Now, if you want, you could get plugins and toggle them! You will get more windows if you do that.

Inserting A Part

It’s really simple to insert a part. All you have to do is go to the top where MODEL and VIEW is, and find HOME (I believe it’s called that). Once you press on it, you will see a button called “Part”. Click on that and there you have it, a part inside your workspace.

Renaming Something

Renaming parts or anything is very useful. For example if you insert a remote event (We will get onto inserting things later on) and you just keep the name as remote event, and you place in another one and its the same name, and you want to fire the event (I will talk about firing it in a different part), the script will be confused on which to fire.

Services

If you look at your explorer, you can see things such as ReplicatedStorage, ServerScriptService, etc.

ServerScriptService basically where most of your scripts are stored. No exploiters can access to it, unlike the other services, exploiters can.

Have you ever played simulators? There’s probably a shop GUI.

StarterGui is where all your GUI’s are stored. But to insert a frame or a text button, etc, you need to insert in a screen gui.

ReplicatedStorage is where mostly your remote events are stored. What remote events do are for example you are making a super power training game and you want your client/player to have a fly ability. You would want to add a remote event in there and rename it to flyEvent.

ServerStorage is basically the storage I guess.

Scripts

In roblox studio, there are scripts. These scripts tell the computer on how to run the game.

Server scripts/scripts run on the server.
Local scripts run on the client. The client is basically a player.
Module scripts make scripting easier. They are mostly put in scripts.

Inserting a script

This will be an important part of this guide- inserting a script.

Inserting a script is very simple, all you have to do is hover over something in the explorer. Can be ServerScriptService, StarterGui, etc. If you hover over anything then a + sign will show up at the side. You can click on that then this will show.

Then you could search “script”
You can just click on the server script.

Printing

Since printing will be used later, I will explain it now.

If you do-

print(“Hello world!”)

-and press Play/Run, inside your output you will see “Hello world!”
You can place whatever you want inside those parentheses.

Console

If you play a game and you’re too lazy to open up your output from the view tab, you can press F9 or inside the chat you could say- “/console”

Either way, it will open up this

Data Types

‘What are data types?’ you must be asking. Well they are really simple!

String Values

Strings values are basically text. Well not this kind of text. They are like “this” or ‘this’. They can even be like [[this!]] Wow who knew?

Example:

print(“Hello world!”)

Over here, “Hello world!” is the string.

Booleans

Booleans can be called bool values too! Anyways, what booleans do are a true or false value. Very simple!

Example:

IHaveDogs = true

Over here, the IHaveDogs global variable is set to true. But if it were false, well you would probably know.

(We will talk about global variables later)

Tables

Tables can be columns or arrays, but in this case, I’ll use an array.

Let’s say we have a dog right? So let’s set a variable for that dog.

Dogs = {}

These {} are a table. Let’s add some things to it!

Dogs = {“White”, “Black Spots”, “Really Big”, “Man idk if it’s a dalmation or a great dane”}

The commas in the table are like telling the script that there is another object inside the table. If you don’t add the commas, you will get an error (please don’t put a comma at the last object).

Number Values

Good old 1, 2 and 3.

Nil
Nil basically means nothing.

Variables

Global Variables

It’s really simple. Here’s and example.

hi = 2

or

goodbye = false

Local Variables

Yeah let’s say for example, you inserted a part inside your workspace and you named it to sjsjasjkdjsdsfasfdsfg for whatever reason. Now, you don’t want to change the brickcolor of the part by doing

sj

looks at explorer

sjjas

looks at explorer again

Yeah that’s gonna be a long time.

Fortunately, there are local variables.
How you can use them is like-

local pt = game.workspace.

Each . is referencing something. In this case we are referencing the game and then the workspace. After you type workspace in, options might show. What you need to type in is the first or first two letters of that part. Then when that option shows, press enter. But make sure the option is your part. If you see it but its not selected, you can press the down or up arrow keys. If that doesn’t work you can just select it with you mouse or touchpad.

If Statements

Remember booleans? We will be using them for this example!
What if statements do are basically like for example, if a player touches a part and you want the part to fall when they touch it, you will probably use if statements. I will show you an example. (This example wont work if you try it)

touchingPart = false
if touchingPart = true then
touchingPart.Anchored = false

You will have an end)/end at the end of your script. What ends mean are basically that’s the end of that part of the code.

Do you see a .Anchored? Well I haven’t explained that yet, but basically if you want a part to stay in the air, you anchor it. If you don’t anchor it and you want it to be in the sky, well it’s gonna fall. Also make sure to anchor your part if you do a falling part script.

Here’s another example!

oldestPerson = 134 – Global variable and its a number value
if oldestPerson = 100 then
print(“Oldest person alive is 100!”) – Will print it to the output

Functions

Functions are easy to understand (maybe). Here is an example for a function.

function Name()

Each function has a name. I cannot start with a special character like @ or like *. You cannot start with a number too. But what you can do is Name() or Name4(). It is important to have () at the end of your function’s name.

Now lets make our function do something.

function Name()
print(“Hello world!”)

Now this function is gonna print something. But wait! This won’t work. That’s because we haven’t called the function.

Don’t forget to have end too!

Calling a Function

Calling a function is simple. Here’s what it is!

function Name()
print(“Hello World!”)
end)
Name()

We have to say the name of our function if we want to call it. Now if you run this, it’s gonna print ‘Hello World!’ now!

Connecting a Function

Connecting a function is basically like

players.PlayerAdded:Connect(function()

What this code I’ve written do is whenever a player joined something, it does whatever is underneath.

‘Why do we connect a function?’ you ask. Well what this does is whenever an event fires (which in this case when a player joins and event is being fired), it will happen every time. Basically we don’t need to do anything for each client (probably won’t make sense).

Ah, sorry to whoever’s reading, I’m gonna take a break, so I’m just gonna stop this post here. I will continue this though.

23 Likes

This topic is just not beginner friendly. You’re explaining things way too much and you haven’t even explain how they can use the print() function to print out values. You should’ve explained how to insert a script, what this script do and only a few data types before going crazy.

I wouldn’t recommend this tutorial to a newbie as this tutorial isn’t well professionally made. This needs a lot of improvements.

5 Likes

Ah right, sorry. I forgot to explain the print() function. Sorry about that! I fixed it now.

1 Like

You should explain how to insert a script in it as well.

1 Like

Sure, I can do that I guess. I apologize.

1 Like

also explain a good reason why I should use bool values, and explain how to use if statments

1 Like

Maybe that’s too much, they should just explain what is a print statement, some basic data types and the use of variables.

1 Like

Yeah but if statements are SO USEFUL! It’s something you NEED to know when you first start to learn to script

1 Like

I know, but that should be in another tutorial as they’ll get confused a lot when they are absorbing new knowledges.

2 Likes

Thanks for the resource! This will definitely help new developers! I got a question though, as I’m pretty stupid, what does

do?

For example, if you misspell something in your script, you will automatically see an error inside the script analysis. It’s not like the output where you have to play it and it will show the error.

Script Analysis is a tool inside Studio that you can find in the View section of the top menu.

It will display all the errors in your code. EXTREMELY useful and has saved me many times.

How do you access the Script Analysis?

Basically the same as the output, go to the top and press the tab named VIEW. Then you will see buttons on the bar and find script analysis.

(It’s under output)

Great post, basically covered what I learned from Alvin blox tutorials + some other roblox tutorials. I’m kind of stuck on “connect” “events” with scripts, so I’d be grateful if you could add that as well, or maybe link a tutorial to it as well. Thanks for your great worl.

This is a link to connections. But basically it just fires an event every time. For example if a player clicks on a GUI, or if a player joins a server.