Case study

My Roblox framework how it's put together

The codebase I start every Roblox game from. It covers what any game needs before gameplay: startup, networking, saves and UI, with written rules that keep the code maintainable as the project grows.

Role
Sole author: design, code, tests
Type
Internal framework, closed source
Year
2026
Stack
Luau, Rojo, Wally, Fusion, ProfileStore, Lune
ReplicatedStorage/Core/Boot.lua
--- Sorts entries by LaunchPriority (smaller first, default 0) then by name.
function Boot.order(entries: { Entry }): { Entry }
	local sorted = table.clone(entries)
	table.sort(sorted, function(a, b)
		local pa, pb = priority(a), priority(b)
		if pa ~= pb then
			return pa < pb
		end
		return a.name < b.name
	end)
	return sorted
end
Real excerpt. Boot order is deterministic, never the random order of pairs().

01

Context

Every Roblox game needs the same groundwork before the first mechanic: a startup sequence, remotes, saves, menus, admin tools.

Rather than rewriting them for each project, I gathered them into a reusable framework. It deliberately contains no gameplay: shops, currencies or quests are added on top, following the same rules.

02

Problem

Roblox codebases tend to drift into the same failure modes:

  • Trusting the client. Remotes created anywhere, payloads never validated, no rate limit.
  • Fragile saves. Data written from many places, half-applied changes when a script errors, two servers writing the same save.
  • Leaks and wasted frames. A Heartbeat connection per script, loops nobody stops, tables keyed by players that are never cleared.
  • Startup races. Modules depending on the random order of pairs(), and one crashing module taking the rest down.

03

Role

I designed and wrote the framework on my own: the architecture, the core modules, the rules document, the Lune tests, the convention linter and the CI pipeline.

04

Process

1. Services, controllers and an ordered boot

One ModuleScript is one service on the server or one controller on the client. Both sides start through the same Core/Boot, in three phases:

  • require every module under pcall, so one broken module is isolated and listed in a single boot report;
  • Init() of each module, in order and synchronously (connections, resolution);
  • Start() of each module, in order, each in its own thread (loops, waits).

The order comes from LaunchPriority, then the name. NetService runs at -100 so every remote exists before any Init, and PlayerData at -50. A module does nothing at require time, and the client always sets ClientBootstrapped, even after a failure, so a loading screen can never hang.

2. A network layer that validates and rate-limits

Everything goes through ReplicatedStorage/Net; nobody calls Instance.new("RemoteEvent"). A remote is declared once, with its direction, its validator and its rate limit:

Net/Definitions/Combat.lua
Net.define("Attack", {
	kind = "event",          -- "event" | "unreliable" | "function"
	direction = "c2s",       -- "c2s" (client -> server) | "s2c"
	validate = t.table({ targetId = t.number({ integer = true, min = 1 }) }),
	rateLimit = { perSecond = 4, cooldown = 0.2 },
})
Real excerpt from the framework README (comments translated).
  • A client-to-server remote without validate is an error at declaration time. Invalid payloads are rejected before the handler, and t.table refuses unknown keys.
  • Default rate limit: 30 calls per second, per player and per remote, tightened for anything expensive. Rejections are logged at most once every 10 seconds.
  • A handler that crashes never breaks the remote for other players. Server-to-client functions are forbidden, because a client could block the server.
  • The payload is an intention, never an amount, price or reward. The handler re-checks distance, ownership, state, cooldown and balance.

3. Transactional player data and migrations

Saves run on ProfileStore, behind a single write path: PlayerData.Mutate(player, key, fn). The mutator works on a copy, and nothing is written unless it succeeds.

Services/PlayerData/Core.lua
function api.Mutate(
	player: any,
	key: string,
	mutator: (current: any) -> (any, string?)
): (boolean, string?)
	local profile = profiles[player]
	if not profile then
		return false, ErrorCodes.NoProfile
	end
	if isPrivate(key) or options.template[key] == nil then
		return false, ErrorCodes.UnknownKey
	end
	local working = deepCopy(profile.Data[key])
	local ok, result, reason = pcall(mutator, working)
	if not ok then
		return false, ErrorCodes.InvalidValue
	end
	if result == false then
		return false, reason or ErrorCodes.Rejected
	end
	local newValue = if result ~= nil then result else working
	-- (type check and NaN / infinity guards omitted here)
	profile.Data[key] = newValue
	markDirty(player, key)
	return true
end
Real excerpt, shortened: one guard block is elided where marked.
  • It returns (true) or (false, code) and never raises. A mutator that errors halfway leaves the data untouched.
  • Dirty keys are flushed as one network patch per player per frame. Keys starting with _ (version, receipts) never reach the client.
  • Changing the shape of existing data means a new numbered migration, each run once and in order, after a reconcile that fills missing template keys.
  • If another server takes the session, the player is kicked here, so two servers never write the same save. Purchase receipts are idempotent by purchase ID.

4. UI with Fusion

  • Panels follow one contract (Init, Activate, Deactivate, Destroy) and are built with Fusion from a template folder.
  • A navigation controller owns the panel stack and its animations; a panel never opens itself.
  • UITag declares button behaviour (hover, press, open, sound, action) with Studio tags and attributes instead of code.
  • Long lists reuse cells with UIListKit. ResponsiveScale handles screen sizes, with touch targets of at least 44 px.

5. One Heartbeat and a cleanup bag

Every periodic task goes through Scheduler.Every(name, hz, fn) instead of its own loop. Start phases are spread with the golden ratio, so two tasks with the same rate never land on the same frame, and cosmetic tasks slow down with graphics quality.

ReplicatedStorage/Core/Scheduler.lua
local handle = Scheduler.Every("Pickups", 10, scanPickups) -- 10 Hz
handle:Disconnect()

-- Golden ratio conjugate: (i * GOLDEN) % 1 fills [0, 1[ evenly for any task count.
local GOLDEN = 0.6180339887498949
Real excerpt: usage from the module's doc comment, and the constant.

Everything a feature creates goes into a Bin, and one Clean() releases it all, in reverse order:

ReplicatedStorage/Core/Bin.lua
local bin = Bin.new()
bin:Add(part.Touched:Connect(onTouched))        -- RBXScriptConnection
bin:Add(Instance.new("Highlight", model))       -- Instance (Destroy)
bin:Add(Scheduler.Every("Spin", 10, spin))      -- anything with Disconnect / Destroy
bin:Add(function() print("cleaned") end)        -- plain function
bin:Clean()                                     -- releases in reverse order, reusable
Real excerpt from the module's doc comment.

6. Tooling that enforces the rules

Rules only hold if a machine checks them. Rokit pins the toolchain (Rojo, Wally, Selene, StyLua, Lune, luau-lsp), and the same checks run in a pre-commit hook and in GitHub Actions:

CommandChecks
stylua --checkFormatting
selene srcLint
luau-lsp analyzeStrict typing across the whole project
lune run scripts/lint-conventions--!strict on line 1, pcall budget, deprecated APIs, remotes outside Net
lune run tests/runCore tests: Signal, Logger, Scheduler, Boot, Bin, Net, PlayerData
rojo buildThe project builds

05

Solution

The result is a base where the safe path is also the easy path. Three event buses keep responsibilities apart:

BusScopeFile
Netclient ↔ serverReplicatedStorage/Net
GameEventsserver ↔ serverBootstrapper/GameEvents.lua
EventBusclient ↔ clientBootstrapper/Events/

On top of the core, it ships the services every game ends up needing: settings, moderation with text filtering and persistent bans, admin commands checked by UserId, notifications, teleports with retries, analytics with a client whitelist, monetization with idempotent receipts, and a movement anti-cheat. Adding a feature follows a written recipe, from a new remote to a new panel or feature flag.

06

Result

13

server services ready to use

8

client controllers

7

core test suites run by Lune

6

pinned tools in one rokit install

Counted from the framework repository (README service tables, tests/ folder, rokit.toml), December 2026.

I now use it as the base for my projects.

07

What I learned

  • Make the safe path the default. Rules people have to remember get forgotten. A missing validator that fails at declaration does not.
  • Keep the core pure. Injecting the clock, the store and the spawner made Boot, Scheduler and PlayerData testable in Lune without opening Studio.
  • Write the rules down. A short rules document plus a linter onboards a new scripter faster than any code review.

08

Stack

  • Luau --!strict
  • Rojo 7
  • Wally
  • Rokit
  • Fusion 0.3
  • ProfileStore
  • Selene
  • StyLua
  • luau-lsp
  • Lune
  • GitHub Actions

09

See more

The framework isn't public. I'm happy to go through it in more detail on a call.

Get in touch