Book Image

Mastering Roblox Coding

By : Mark Kiepe
Book Image

Mastering Roblox Coding

By: Mark Kiepe

Overview of this book

Roblox is a game platform with over 47 million daily active users. Something unique to Roblox is that you’re playing games made by other gamers! This means that you can make your own games, even if you have no experience. In addition, Roblox provides a free engine that allows you to create and publish a simple game in less than five minutes and get paid while at it. Most Roblox games require programming. This book starts with the basics of programming in Roblox Luau. Each chapter builds on the previous one, which eventually results in you mastering programming concepts in Lua. Next, the book teaches you complex technologies that you can implement in your game. Each concept is explained clearly and uses simple examples that show you how the technology is being used. This book contains additional exercises for you to experiment with the concepts you’ve learned. Using best practices, you will understand how to write and build complex systems such as databases, user input controls, and all device user interfaces. In addition, you will learn how to build an entire game from scratch. By the end of this book, you will be able to program complex systems in Roblox from the ground up by learning how to write code using Luau and create optimized code.
Table of Contents (16 chapters)
Part 1: Start Programming with Roblox
Part 2: Programming Advanced Systems
Part 3: Creating Your Own Simulator Game

Creating custom events

Previously, we learned that no event gets fired when a character jumps. We started listening to a changed event on a property. This works perfectly. Our current script changes the color of the avatar on a jump change. But what if we wanted to create another script that slowly increases the size of the player’s head. This script needs to listen to the same Jump property, too. Multiple scripts having the same code is a Bad Smell. This is where Custom Events come in handy.

In the following sections, we will learn how to create custom events using bindable events and functions. After that, we will compare them to modules. Finally, we will combine bindable events and modules.

Using bindable events

To make our custom event, we will make a new script. This script will be responsible for managing the event. Then, other scripts can listen to this new event.

But how do we make a custom event? Roblox has something called BindableEvents. These are instances...