Roblox coding for beginners — part 1
You have downloaded Roblox studio (have you? https://www.roblox.com/create ) and want to create your first game. Now what?
This is the first of a series of tutorials that will get you started with the basics of Roblox coding (or scripting for the more tech-savvy readers out there). Roblox uses a scripting language called Lua, or rather a slight variation of it called Luau. Whilst it can be tempting to start copying and pasting code from the internet (I have been guilty of that at times) to obtain instant results, there are some more theoretical concepts you should understand first.
In this article we are going to look at using code to change the properties of bricks in a game, also known as referencing. The properties we are going to look at are transparency and colour.
However, before we even get into the code, let me show you how to set everything up.
Start with an empty baseplate. I know it’s tempting to get started with one of those beautiful templates, but it will just confuse you if you are trying to understand the basics.
Roblox Studio game engine is not the easiest to navigate and I underestimated that so many times. I often wanted to get to the coding part of a lesson but kids did not even know where to write the code in the first place. So here are some basic concepts you need to know.
How to insert a part
How to move that part around
How to make the part bigger or smaller
How to rotate that part
How to make the part do things
When you go to view and then click on explorer, you will see all the elements of your game. One of them will be the part you just inserted. To make parts do things, you need to insert elements inside it and you do that by clicking on the little plus sign.
Now let’s code
Insert a script inside your part by clicking on the little + sign like I mentioned before.
Let’s do some referencing.
Referencing is writing code to change the characteristics of a part such as its transparency or colour.
There is a certain hierarchy we need to follow to do referencing properly.
Now let’s put that hierarchy into practice
In the script of your game, write the following:
game.Workspace.part.Transparency = 1part is the name of your part but it could be anything. You could name it hello, part1, part2… as long as the code matches what you called it.
Get Costi tech’s stories in your inbox
Join Medium for free to get updates from this writer.
THE ONE BELOW IS CORRECT
THIS OTHER ONE WILL NOT WORK
Transparency is the name of the property/characteristic of the part you want to change. We used = 1 because you change transparency using numbers but remember that is not always the case. Now let’s test it. Click on “Run” under the “test” tab and you will see the part disappear. That is because we have made it very transparent.
Now let’s put the hierarchy into practice again by changing the part colour
The process is the same.
1 Game
. (dot)
2 Workspace
. (dot)
3 Name of the part
.(dot)
4 Property of the part to be changed
=
5 How you are going to change that property
Put the following code in your script
game.Workspace.part.BrickColor = BrickColor.new ("Really red")As you can see, the property here is called BrickColor instead of Transparency and we change the color using text rather than numbers. The text in question is BrickColor.new (“Really red”) but you could change that to any other color you like. For example (“Sea Green”).
Now let’s test it. Again, click “Run” under the “Test” tab in Roblox Studio.
That’s it for today. It might not seem like you learnt a lot but you are going to thank me when you will create more complex games. The basics are everything, just like in any other learning domain.
Do you have any questions regarding Roblox coding? Comment on this article










