What is Lua?
And what exactly is a programming language?
Well, at their most fundamental level, CPUs are made up of switches. A mind-boggling number of switches but still switches nonetheless. And because a switch only has two states, on or off, CPUs too are limited to working in some combination of these states. More accurately, in 1’s and 0’s, which we call the binary number system.
But computers are only useful if they can execute instructions that we provide. And humans are bad at remembering things and even worse if that thing they had to memorized also had to be encoded in 1’s and 0’s.
So on the seventh day, God created programming languages so that his children would never have to program in 1’s and 0’s again. Or maybe something that like.
A programming language defines a set of syntax and semantics for writing instructions in a human-readable format. This is often referred to as ‘code’ or ‘source code.’
Before these human-readable instructions are given to the CPU, one or more intermediate steps also take place along the way until at the other end pops out the 1’s and 0’s the CPU needs in order to execute.
There exists many different programming languages. And perhaps you’ve heard of some them before: Java, C++, Python, Javascript.
For Roblox game development, that language is Lua—a lightweight, high-level language that runs on a “virtual machine” in the Roblox game engine itself.
Lua hides away much of the complexities of a language, making it an easy language to learn and allows developers to focus on development while still being efficient and fast.
Source code is written onto text file-like containers called scripts.
In Roblox development development, you will encounter three types of scripts: Script, LocalScript, and ModuleScript.
Scripts (capital ‘S’) are server side scripts and normally only be executed by the server. By default, Scripts that are descendants of workspace and ServerScriptService are automatically executed.
LocalScripts are client only scripts. When placed in client script containers such as the PlayerGui, PlayerScripts, or Backpack, these are automatically be executed by the client.
ModuleScripts are a special type of script used for containing “re-useable” code. ModuleScripts do not execute by themselves but instead, are “called” (loaded) by Scripts and LocalScripts.