Programming: The Absolute Basics - Developing the mindset

Introduction
Most scripting tutorials start by introducing various concepts available in Lua and providing the functionality that those commands do - but it can still be difficult for beginners to take those commands and actually use them to start writing their own code.

This tutorial takes a different approach. Rather than introducing the functionality that Lua provides, I’m going to start off by talking about a very core aspect of programming - writing down processes in a series of steps.

Why Bother with Steps?
No matter the language, programs serve to provide one function: telling a computer what to do. This is the same case with scripting in Roblox; when you write a script, that script is designed to communicate to the Roblox engine what should happen in your game. But as the programmer, your job is not to learn how to think in code - instead, your job is to divide your problems into simple steps which can be eventually translated into code.

Take a simple example. In most obstacle courses, there’s a concept of lava - when a player touches the lava, they’ll die. The objective is to jump past all these lava parts to move on in the course.

But how does lava actually work? If you jump into Studio and look at the code, it can look mystifying - there’s a lot of weird words, a mix of brackets, etc., and to somebody not well experienced with Lua, this can be very difficult to make sense of.

But that’s where writing the steps out can come into play. The typical process taken by lava is:

  1. Something touches a part
  2. Is the thing making contact a player?
    If it is:
    3. Kill that player.

And while this may not help to make sense of the actual code that you’d see in a script, it’s something that you should be able to make some sense of for yourself: it’s written out in English, and it seems to follow a simple process.

That’s all a program is doing - the only difference is that Lua is designed to make sense of those steps for the computer, while writing it in English is designed to make sense of it for you as a person.

So how do I come up with the steps, then?
For someone just starting out at the craft, identifying the steps for a process can be difficult - but it’s something that you can become an expert at with enough practice.

One way of doing it is to imagine that you’re talking to a younger sibling and trying to explain the concept to them, provided that they’d have basic knowledge, but would have had no prior experience with it.

Let’s start with an idea of making a bowl of cereal (the cereal goes first, of course!). What would the steps look like for something like that?

First, we’d want to grab the box of cereal, a bowl, and some milk. We’d pour the cereal into the bowl, then proceed to fill it with milk. Finally, we drop a spoon into the bowl, put back the cereal box and milk, and we’re done!

Written as a list, this would be along the lines of:

  1. Grab the bowl, the cereal box, and the milk
  2. Pour the cereal into the bowl
  3. Pour the milk into the bowl
  4. Put a spoon into the bowl
  5. Put the cereal box and the milk back
  6. Eat the cereal!

Now let’s look at something more along the lines of scripting for Roblox. Say you have a teleporter - when somebody steps in one side, they end up at the other. What would the steps look like for something like that?

  1. An object touches one end of the teleporter
  2. The teleporter checks that it was touched by a player

If the teleporter was touched by a player:
3. The script determines the position of the other end of the teleporter
4. The script places the player at the position of the other teleporter

You can also come up with examples of this from your own games, from your own homes, etc. This is one of the most key skills you’ll need as a programmer, so it’s definitely something that you’ll want to get enough practice with.

Moving Beyond / Conclusion
This tutorial has introduced a three step framework for programming:

  1. Determine the problem you’re trying to solve
  2. Simplify the problem into a series of steps
  3. Determine the code needed to drive that process

It does not, however, provide a deep dive into the commands that are offered by Roblox and Lua. For that, there are many other tutorials, with some being linked in the Additional Resources section below. This tutorial was rather designed as a way of bridging the gap between what those tutorials teach and the problems that you may face: how can you think in terms of steps and guide those steps into statements of code.

Thank you for reading, and please feel free to message me or respond with any questions - this will allow me to improve the tutorial and offer a better guide to everyone looking to start with programming. I also suggest diving into many of the other tutorials that I will link below in order to dive deeper into the step of writing code.

Additional Resources
AlvinBlox has an excellent series of scripting tutorials for beginners on YouTube: https://www.youtube.com/watch?v=BfLUt3mfJiY

As well as the wiki, which provides many excellent written articles: Documentation - Roblox Creator Hub

The wiki also provides an API listing for everything which you may have to interact with, which can be found using the search function on the Roblox wiki: Documentation - Roblox Creator Hub

Finally, looking into flowcharts may help you to grasp the step-by-step process of programming - while also providing a useful tool for looking at this kind of thing visually. There’s a lot of tutorials available if you search it up on Google, and @Thundermaker300 below provides a nice intro into it - so definitely look into that if you’re interested!

48 Likes

Good tutorial! In terms of developing the steps toward a program, it might be worth mentioning the usage of flow-charts. Just talked about these in my programming class in school the other day. Essentially, flow-charting is a way to “outline” your code in a sense, or get an idea on what will happen in a series of steps. A good one that I recommend is draw.io. There are different symbols for different functionalities, such as data storage, if statements/choices, etc, and it connects directly to Google Drive, OneDrive, or the device itself. It also comes with basic features that are nice to have, such as adjustable arrows, looping (pointing the flow-chart back to itself), etc.

Often used flow-chart symbols

From this website.
flowcharts

Other than that though, great tutorial, and nice job expressing the need to create a step-by-step list to programming. Really important stuff for any project!

9 Likes

I think the idea of flowcharting is interesting - it definitely does help to describe the process, but I think it’s more complicated than I’d like to get into with this kind of tutorial. For somebody who’s just starting out and doesn’t know how to code, I think the diagrams would be kind of scary - they’d probably just want to get into what a program actually is.

That being said, it’s definitely a topic that everyone going beyond into more advanced programming should get into. I think I’ll add it into my “Further Reading” section as another resource that people can look into if they want to go further. Could also be useful as an additional topic if I write up another tutorial, which I’ve been thinking about doing.

Thanks for the feedback, by the way! I’m hoping for this to be something that people can look at to get a quick intro to programming and the feedback definitely helps in doing that.

1 Like

Yeah, I get what you’re saying. Personally I think that flow-charting is better for bigger projects because smaller projects might just find it easier to list the steps in order. However bigger projects that require loops, ifs/branching, data saving, etc might find it easier to use flow-charting. I think it’d be good to include in a further reading. Np for the feedback!

2 Likes
  1. Pour the cereal into the bowl
  2. Pour the milk into the bowl

Glad to see you’re not one of those monsters who pour the milk first.

Jokes aside, this tutorial I think is good for beginners. A lot of new scripters just jump straight into it without understanding where to go or what to do.

I just find it odd how some of the segments are spoilers, some are lists, one is a code block, etc.

8 Likes

The spoilers are basically for people to experiment with it on their own to see if they can get the steps thing down. Although that lava one should probably not be a code block - I’ll fix that.

And nobody actually does the milk first right?! lol

2 Likes

Ahh I see. Well nice tutorial !!

I’ve only heard rumors of those people… o.o

3 Likes

This has really had a change on the way I construct scripts, thank you for sharing this. Its a great way to plan your scripts.

3 Likes