James Onnen (Quenty)
Roblox Development
Published in
3 min readAug 31, 2018

--

This article was originally published in THEM magazines.

Roblox Development Script Architecture

Good scripting won’t make a good game. But it can help you iterate faster, save yourself headaches, and make your game less buggy.

There are two basic ways to setup your scripts on Roblox. I’m not sure if most new Roblox developers are aware of how most games are setup. There are two setups, multi-script architecture, which most scripters start out with, and single script architecture, which most games on the front page use.

Today I’m going to talk about why it’s preferential to use a single script to load things, a pattern that may not be immediately clear to new developers.

Multi-script architecture

Most scripters start out with a multi-script architecture. If you have more than one script

The original Apocalypse Rising uses a multi-script architecture. That is, scripts are spread across the game.

Apocalypse 1 uses a lot of small scripts and a few modules. You can see code is duplicated

Because of this, Apocalypse Rising ended up using a lot of _G, which is definitely an anti-pattern in scripting on Roblox.

The argument for a single-script architecture

Most scripters starting out have a lot of scripts everywhere, especially since most scripters learn from free models. Naturally free models contain all of their own code.

However, as you start to program larger games, it becomes a lot easier to use a single script. This involves using ModuleScripts to load reusable code from a single script, which can bind all the modules together.

You see, code in multiscript architecture has trouble communicating with each other. For custom effects not built into Roblox’s engines, this can require careful coordination. Without shared module scripts, other code has trouble communicating without _G or other workarounds. Furthermore, passing complex data structures around becomes increasingly expensive or messy as you keep scripts separate.

The solution is the single-script architecture.

“Communication and hierarchy are hugely important and that’s not easily done with a multi-script style code base”

- Liam Hutch, developer of Apocalypse Rising I and II

Liam actually developed a single-script architecture when developing Apocalypse Rising II. Apocalypse Rising II has less code and more functionality than its predecessor, thanks in part to a single-script architecture.

In comparison, Apocalypse Rising 2 does more with less code! Keep it simple!

Using a single-script architecture is used in most front page Roblox games. These games benefit from controlling when code executes, sharing data structures, better performance, and better code. Code is generally maintained in a single place in the game, and this makes it easier for people to collaborate with modules.

Skybound 2, by Imaginareum, and WFYB both use a single script architecture. As do many other games.

“It’s not obvious, but modules keep everything clean.

The first thing I teach my friends to do when learning to code is module-hierarchy

I think it’s one of the most important things for new coders to manage the scope of what they have to look at so they don’t get confused.”

- Imaginaerum, developer of skybound 1 and 2

Overall, I would highly recommend loading your games from a single script. A single-script architecture can help you avoid programming issues and let you iterate and test your game faster. Furthermore, it’ll help other people program with you.

~ Quenty

--

--

James Onnen (Quenty)
Roblox Development

I’m a maker. Designing and creating new things with people is my hobby. Former intern @Microsoft, @Roblox, @Garmin. Roblox Toy. Raikes 2019.