In short
When a script calls require on a ModuleScript, Roblox runs the module once and hands back the one value it returns, usually a table. If the module reaches its end without a return, or returns two values, the require fails with this error. Add a single return at the very bottom of the module, usually return Module, and make sure nothing else returns from the top level.
What the message means
ReplicatedStorage.Config:12: Module code did not return exactly one value
The script named in the message is usually the ModuleScript itself. The script that called require also fails, often with Requested module experienced an error while loading.
A new ModuleScript starts with local module = {} and return module. Deleting or moving that last line is the most common way to get this error.
Causes and fixes
Three things cause this error in practice. Each one below has the smallest code that triggers it, then the fix.
The module has no return at the end
The return line was deleted, or new code was pasted below it and the return got lost.
local Config = {}
Config.StartingCoins = 100
Config.MaxPets = 3
End the module with one return of the table.
local Config = {}
Config.StartingCoins = 100
Config.MaxPets = 3
return Config
The module returns two values
Returning two things, like return Shop, Prices, is fine in a function but not in a module. A module gives back exactly one value.
local Shop = {}
local Prices = { Sword = 100 }
return Shop, Prices
Put everything into one table and return that.
local Shop = {}
Shop.Prices = { Sword = 100 }
return Shop
The return only runs in some cases
A return inside an if at the top level only runs when the condition is true. When it is false, the module ends with nothing.
local RunService = game:GetService("RunService")
if RunService:IsServer() then
return { side = "server" }
end
Build the value in the branches and return once, at the end.
local RunService = game:GetService("RunService")
local Side = {}
if RunService:IsServer() then
Side.name = "server"
else
Side.name = "client"
end
return Side
Fix it in your place
Paste the error, RoCode fixes it in your place
Copy the line from Output and paste it here. RoCode opens the script it names in the place you have open in Studio, works out which of the causes above it is, and edits the code there instead of handing you a snippet to paste.
RoCode is an AI agent for Roblox Studio: it reads the scripts in the place you have open, finds the line and edits it there, and every change is an undo point. It runs on Windows or macOS with a desktop browser. Free to start, with free credits every day.
How to find the line that causes it
- Open Output (Window menu, or the Script tab), clear it with Ctrl+K (⌘K on Mac), and press Play.
- Find the first red line. It starts with the script's place in the Explorer and the line number, such as
ServerScriptService.Shop:12:. - Click the red line. Studio opens that script with the cursor on the failing line.
- Read the lines between
Stack BeginandStack Endunder it: they list the calls that led there, newest first, so you can see which function called the broken one. - Still not sure which value is wrong? Add
print(typeof(x), x)just above the line, or set a breakpoint on it and read the values in the Watch window.
Questions
Can a module return a function instead of a table?
Yes. A module may return any one value: a table, a function, a number or a string. One value is the rule, not the type.
Can I return nil from a module?
No useful way: returning nothing, or nil, gives this same error. Return an empty table if there is nothing else to share.
Why does the error mention my Script and not the module?
The script that called require fails too. Click the message in Output, follow it to the ModuleScript named in the first error, and check its last line.
Can RoCode fix it?
Yes. Paste the Output line into RoCode. It opens the module in your place and fixes its return.
Sources and further reading
- Roblox Creator Docs: ModuleScript. a module returns exactly one value
- Roblox Creator Docs: reuse code with modules
How the code was checked: every block marked Fixed passes Luau's strict type checker against Roblox's API definitions (luau-lsp, 12 November 2026), and every block marked Breaks compiles and fails only when it runs. The message wording was checked against the strings in Roblox Studio itself (macOS build installed on 12 November 2026) on 12 November 2026. A type check catches misspelt APIs and wrong types, not game logic, so playtest in Studio before you publish.