Roblox Wiki
Register
Advertisement
Roblox Wiki

The Roblox engine converts high-level Lua code into the lower-level bytecode, a form of instruction set, before being able to execute code. This process is done every time the engine executes a Lua program such as a script or a plugin.

loadstring[]

Previously, both servers and clients were able to load raw Lua bytecode through the standard Lua library function loadstring, and it was often used for one of two purposes:

  • Obfuscating the script's source code, to avoid modification– aiding particularly to avoid model copying.
  • Malicious scripts which would use flaws in the verification algorithm to perform things they shouldn't be able to normally.

Roblox stopped supporting bytecode execution on August 3, 2012, for security and version compatibility reasons.[1]

Places[]

It is known that popular places, such as Wingman8's Galleons, were left broken due to them using bytecode as an obfuscation method. Galleons were fixed in January 2020.

Usage[]

As an example of bytecode and loading of it, consider the following "hello world" script's source code:

print("Hello World!")

Which would yield the following bytecode, represented as an hex dump for readability:

00000000 1B 4C 75 61 51 00 01 04 04 04 08 00 12 00 00 00 .LuaQ...........
00000010 3D 57 6F 72 6B 73 70 61 63 65 2E 53 63 72 69 70 =Workspace.Scrip
00000020 74 00 01 00 00 00 03 00 00 00 00 00 00 02 04 00 t...............
00000030 00 00 05 00 00 00 41 40 00 00 1C 40 00 01 1E 00 ......A@...@....
00000040 80 00 02 00 00 00 04 06 00 00 00 70 72 69 6E 74 €..........print
00000050 00 04 0C 00 00 00 48 65 6C 6C 6F 20 57 6F 72 6C ......Hello Worl
00000060 64 00 00 00 00 00 04 00 00 00 02 00 00 00 02 00 d...............
00000070 00 00 02 00 00 00 03 00 00 00 00 00 00 00 00 00 ................
00000080 00 00 ..

This bytecode, before the removal of bytecode mentioned above, could be loaded in a standard RBX.Lua script this way:

loadstring('\27\76\117\97\81\0\1\4\8\4\8\0\47\0\0\0\0\0\0\0\114\101\116
\117\114\110\32\102\117\110\99\116\105\111\110\40\41\32\10\112\114\105\110
\116\40\34\72\101\108\108\111\32\87\111\114\108\100\33\34\41\10\10\32
\101\110\100\0\1\0\0\0\4\0\0\0\0\0\0\2\4\0\0\0\5\0\0\0\65\64\0\0\28\64\0
\1\30\0\128\0\2\0\0\0\4\6\0\0\0\0\0\0\0\112\114\105\110\116\0\4\13\0
\0\0\0\0\0\0\72\101\108\108\111\32\87\111\114\108\100\33\0\0\0\0\0\4\0\0\0
\2\0\0\0\2\0\0\0\2\0\0\0\4\0\0\0\0\0\0\0\0\0\0\0')

Native execution[]

On August 31, 2023, Roblox announced a studio beta feature that enables native code generation for Luau. When the feature is enabled, code with --!native will be further complied into native code.[2]

References[]

Advertisement