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

Programming loops

Quite a few times, we have made systems without taking them to the fullest, primarily because we missed knowledge of loops. Loops allow us to repeat a process multiple times without having to copy and paste the same code over and over again. This section explains everything you need to know about loops.

Here is a list of the three different loops that Luau has:

In the following sections, we will dive deeper into each of these loops.

while loops

The first loop we will look into is the while loop. As previously mentioned, a while loop keeps repeating the same code until a condition is met. Let us take a look at the following code:

function randomBoolean()
   return math.random(0, 5) == 0
function countTries()
   -- Counter variable
   local tries = 0
   -- While Loop
   while randomBoolean() == false do
      tries += 1