Reverse Single Script Architecture (RSSA)

:brain: Reverse Single Script Architecture (RSSA)

Takes Single Script Architecture (SSA) and does the complete opposite

RSSA allows normal Scripts and LocalScripts to behave like modules that return values, while using a single ModuleScript as the core of the game.


This is done using two global functions:

_G.Load(script)
_G.Return(value)

:light_bulb: How RSSA works

:check_mark: _G.Load(script)

  • Clones the given Script/LocalScript
  • Runs it inside a designated “Active” folder
  • Waits until the script calls _G.Return(value)
  • Returns that value synchronously

:check_mark: _G.Return(value)

  • Called inside a loaded script
  • Uses debug.info(2, "s") to identify the caller
  • Sends a value back to the loader
  • Works for tables, strings, numbers — anything

:check_mark: No coroutines, no BindableEvents, no other ModuleScripts

Everything is done using Roblox’s existing script runner + a bit of debug metadata.

:check_mark: It’s cursed, but cleanly implemented

RSSA is meant as a fun experiment, but the code is strict-typed Luau, uses clear paths, and works identically on server and client.


:package: Folder Structure

You need two folders on each side:

Server

ServerScriptService

Storage  → contains template Scripts
Active   → clones get parented here

Client

PlayerScripts

Storage  → contains template LocalScripts
Active   → clones get parented here

:wrench: The Core RSSA Runtime

Click to expand full Core code
--!strict
--[[
	RSSA Core (Reverse Single Script Architecture)
	Allows normal Scripts/LocalScripts to behave like synchronous modules.
]]

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")

type Side = "Server" | "Client"
local Environment: Side = RunService:IsServer() and "Server" or "Client"

local Storage: Instance
local Active: Instance

type ReturnMap = {[string]: any}
local Returns: ReturnMap = {}

function _G.Return(Value: any)
	local key: string = debug.info(2, "s")
	Returns[key] = Value or {}
end

function _G.Load(Script: Script | LocalScript): any
	local Loaded: Script | LocalScript = Script:Clone()
	Loaded.Parent = Active
	Loaded.Enabled = true

	local Key: string = Loaded:GetFullName()

	repeat task.wait() until Returns[Key]

	local result: any = Returns[Key]
	Returns[Key] = nil

	return result
end

local Load = _G.Load

-------------------------------------------------------------------------------
-- SERVER EXAMPLES
-------------------------------------------------------------------------------

if Environment == "Server" then
	warn("Server Running")

	local ServerScriptService = game.ServerScriptService
	Storage = ServerScriptService.Storage
	Active = ServerScriptService.Active

	print(Load(Storage.HelloWorld))

	local waited = Load(Storage.WaitExample)
	print("WaitExample:", waited.Message, waited.Time)

	local mathResult = Load(Storage.MathTask)
	print("MathTask:", mathResult.Sum, mathResult.Product, mathResult.Average)

	local serverInfo = Load(Storage.ServerInfo)
	print("ServerInfo:", serverInfo.JobId, serverInfo.PlayerCount)

	local chain = Load(Storage.ChainMaster)
	print("ChainMaster Math:", chain.Math.Sum)
	print("ChainMaster Wait:", chain.Wait.Message)

-------------------------------------------------------------------------------
-- CLIENT EXAMPLES
-------------------------------------------------------------------------------

else
	warn("Client Running")

	local Player = game.Players.LocalPlayer :: Player
	local PlayerScripts = Player.PlayerScripts

	Storage = PlayerScripts.Storage
	Active = PlayerScripts.Active

	local who = Load(Storage.WhoAmI)
	print("WhoAmI:", who.Name, who.Display)

	print(Load(Storage.Debug))

	local numbers = Load(Storage.Numbers)
	print("Numbers sum:", numbers.Value1 + numbers.Value2)

	local info = Load(Storage.ClientInfo)
	print("ClientInfo:", info.Player, info.CameraPosition)
end

return nil

:page_facing_up: Example Scripts (Server)

Place these inside ServerScriptService.Storage


HelloWorld

--!strict
local Return = _G.Return
Return("Hello from the server!")

WaitExample

--!strict
local Return = _G.Return
task.wait(2)
Return({ Message = "Finished waiting 2 seconds", Time = os.time() })

MathTask

--!strict
local Return = _G.Return
local a, b = 14, 28
Return({ Sum = a+b, Product = a*b, Average = (a+b)/2 })

ServerInfo

--!strict
local Return = _G.Return
Return({
	JobId = game.JobId,
	PlayerCount = #game.Players:GetPlayers(),
	Time = os.time(),
})

ChainMaster (Loading in a Loaded Script)

--!strict
local Load = _G.Load
local Return = _G.Return

local s = script.Parent

local mathResult = Load(s.MathTask)
local waitResult = Load(s.WaitExample)

Return({
	Math = mathResult,
	Wait = waitResult,
})

:page_facing_up: Example Scripts (Client)

Place inside PlayerScripts.Storage


WhoAmI

--!strict
local Return = _G.Return
local p = game.Players.LocalPlayer
Return({ Name = p.Name, Display = p.DisplayName, UserId = p.UserId })

Debug

--!strict
local Return = _G.Return
Return("Debug LocalScript ran successfully.")

Numbers

--!strict
local Return = _G.Return
Return({ Value1 = 12, Value2 = 34 })

ClientInfo

--!strict
local Return = _G.Return
local cam = workspace.CurrentCamera
local p = game.Players.LocalPlayer

Return({
	Player = p.Name,
	CameraPosition = cam and cam.CFrame.Position or Vector3.zero,
})

:warning: Warning

RSSA was created to test the bounds of Roblox, it was not designed to be a production system.

It:

  • yields until a script returns (Always return something)
  • uses global state
  • uses debug metadata

But it does work surprisingly well and is great for learning, experimentation.


:tada: Conclusion

This was made for fun, but it demonstrates:

  • Luau’s script identity system
  • how debug.info works
  • creative ways to manipulate Roblox’s script runner
  • how far you can push non-ModuleScript architectures

If you build your own systems using RSSA, feel free to share them.

Credits

  • hank_hail — Developer
  • ratplier — Contributor
  • 1kaelen1 — Contributor
  • apoiiya — Contributor
23 Likes

this is pretty tuff! will use in my next game!

6 Likes

wow! this is so clever. thank you for posting. i will be using this in my next game!

7 Likes

This is extremely useful and may change development as we know it. Thank you so much.

6 Likes

this Hank guy has a very large brain.

8 Likes

Wow… I nearly fell over in my seat from crying so much. It’s just so beautfiul. Bravo, bravo!

5 Likes

This… this really is the next generation. A generation of intelligence and hope for our world. Our forefathers could not have dreamt something as clever as this.

7 Likes


my head cannot process the information I was given and must be ashamed for that.

5 Likes

this is innovative, game changing software.
use RSSA in all of your projects from today!

4 Likes

hey, it’s better than still using knit

5 Likes

Is it a ragebait?
It’s gotta be a ragebait..right?

2 Likes
for _, v in script:GetChildren() do
	if not v:IsA("ModuleScript") then
		continue
	end
	local m = require(v)
	if typeof(m.Init) == "function" then
		task.spawn(m.Init)
	end
	if typeof(m.Globals) == "table" then
		for k1, v1 in m.Globals do
			_G[k1] = v1
		end
	end
end

:scream:

4 Likes

Comparing with a bit of the code from the topic, seems to be more simplistic and less complex to implement with this creation that the OP made

3 Likes

Thanks! I’ll be implementing RSSA (Ridiculously Silly Scripting Abomination) into all of my games, as it’s truly an amazing innovation.

Who needs clean code when you can have this chaotic masterpiece? It’s time to welcome something new and worse, don’t you think?

9 Likes

powered imagination at its finest

3 Likes

Don’t let yarik touch this

7 Likes

Just because you’re negative and don’t understand something, does not make it incorrect. Please reassess your value system and improve as a person before continuing to speak on this matter.

5 Likes

i am actually so stupid that i couldn’t tell if this was just an advanced way of game design or an elaborate joke

4 Likes

I only see performance gain or performance loss
Your argument is overshadowed by noise bias; I can’t hear you.
I reason with facts, not vibes.

2 Likes

It’s a real thing, but it simply overcomplicates things by using a custom hacky implementation of ModuleScripts rather than using official methods. Practically useless, but interesting nonetheless.

3 Likes