So You Wanna Script: A Reference Guide for Everyone Else


Updated: December 07, 2020

Introduction

Greetings! I am NINJAMASTR999, better known as MacAndSwiss across the internet. I am an undergraduate student majoring in Computer Science at the University of California, Riverside, and in my off time, I love teaching others about programming, especially Lua.

Why did I create this thread?

While I do have a YouTube series, which you can find here, sometimes it’s not necessarily easy to link to an off-site resource. In addition to that, I feel that I can express myself easier through text rather than video, as articles are an easier medium to publish to. I often see “how do I start scripting” style posts on the main Roblox Developer Forum, so I wanted to create a place that I could point them to.

Chapter 0: Outlining your Journey

Let’s talk about your journey through Roblox scripting. Everyone starts somewhere along 4 levels of expertise, which I have outlined below:

1. Beginner

You’re probably new to Lua, or Roblox, or both. Maybe you’ve tested some templates, or used some models from the toolbox, but when it comes to making something by yourself, you’re sort of lost.

2. Intermediate

You’ve learned the fundamentals of Lua and Roblox, and you can solve basic problems. You might still be confused about more advanced topics, which usually include Metatables/Metamethods, CFrames, and Datastores.

3. Expert

You have a really solid understanding of how Roblox and Lua works. At this point, it’s less about whether or not your code works, but rather how well it runs.

4. Master

You’re a Lua wizard. You can bend reality to your will, and make the engine do things that were not necessarily intended by Roblox. You might even decide to replace default objects for your own custom ones to fit your needs.

Author’s Note: This is a very, very rough outline and more of a point-of-reference. Please don’t go around telling people that you’re “an intermediate scripter” - just tell them what you can and can’t do, or better yet, what you’ve done in the past.

Chapter 1: Beginners

First of all, congratulations on taking up scripting! It’s something that not a lot of people like to do. You may not know anything about Lua or Roblox’s API currently, but with enough effort, you can script your own game in no time!

Learning the Fundamentals of Programming (in Lua)

Before you can have fun with Roblox, I highly, highly recommend you learn the basics of programming. This includes (but is not limited to):

Resources

Programming in Lua is your best resource for learning about Lua. It goes over pretty much everything that I cover in my videos, and more!

Playing with Roblox

Learned some of the basics? Good, now let’s use them on Roblox instead of just printing stuff out. You may notice that in my tutorials, I sometimes include practices that involve the Lua concept being put into use on Roblox. If you’re unsure about something on Roblox Studio, use the Wiki!

Some things to consider learning about (or knowing) along the way:

Once you have a solid grasp of that (or feel like you do), feel free to move on!

Chapter 2: Getting Better

Congrats! You’re getting good at Roblox and Lua. At this point, there are some new things to learn about, and some old things to improve on.

Networking (not the LinkedIn kind)

Let’s talk about the biggest thing, and your new best/worst enemy, The Server-Client Model.

What is this mysterious model? Can you find it in the toolbox?

Well, in short, the Server-Client Model is the way that Roblox handles information. Before this, information that players sent was just accepted by Roblox, and sent to other players! That means that if you got build tools and started deleting buildings, other players would see you delete them!

In response to a wave of exploiting, Roblox transitioned over to the new model under the name FilteringEnabled. It was optional before, but is now the default and shouldn’t be changed.

Generally, keep LocalScripts away from changing stats, and keep Server (or Regular) Scripts inside ServerScriptService.

Resources

This article by Roblox describes pretty much all you need to know about Networking.

ModuleScripts

Sometimes, you just need to do the same thing from different scripts. That is where ModuleScripts come in. ModuleScripts allow you to reuse code, and keep yourself organized! Check out this article for more information on how to implement it. We’ll also use ModuleScripts in the future when dealing with Object-Oriented Programming.

Data Storage

Ah, yes. Data storage - a hard thing to learn, yet so fundamental to modern Roblox games. If you screw up, you could potentially lose the data for some or all of your players, so don’t mess up!

Resources

This Developer Wiki article should give you more information on handling data stores by yourself.

You should also check out DataStore2, a popular module for storing data and one that handles a lot of backup stuff for you!

Feeling adventurous? Check out ProfileService, an alternative to DataStore2.

Chapter 3: Getting Better(er)

So you’ve gone and gotten good at Lua and Roblox. Like, real good. Like, better than me. But I still think that I can provide some value to you on your way to becoming one of the best!

Object-Oriented Programming/Metatables

Now that your code works, let’s make things a bit more organized. Object-Oriented programming and metatables are one solution to that. If you’re familiar with other programming languages like Java or C++, you’re probably at least somewhat familiar with the idea of OOP.

Resources

Check out this page from Programming in Lua. There are probably other resources out there, but this one covers most of what you need to know.

Data Structures and Algorithms

Oh hey, this is what I’m learning in college right now! In short, DSA is a study of how to store and manipulate data quickly in general. Luckily for us, Roblox Lua already has a built-in QuickSort, but you may want to implement some other algorithms to turn your loooops into loops.

Chapter 4: Godmode

Hello! If you’re reading up to this point, please hire me I’m drowning in student debt you’re pretty much at the point where the known and easily-taught knowledge of Roblox and Lua ends! Have fun experimenting with new Luau stuff, or write some fancy-schmancy new module for the community! The world is your oyster.

Alternatively, go work for Dreamcraft. I hear they’re hiring.

5 Likes