Roblox Studio error

Module code did not return exactly one value

What Module code did not return exactly one value means in Roblox Studio, the three things that cause it with the code that triggers each, and the fix for each one.

Updated 12 November 20263 min readErrorLuauWritten by

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.

On this page
  1. What it means
  2. Causes and fixes
  3. Fix it with RoCode
  4. Find the line
  5. Questions
  6. Sources

What the message means

Output (example)
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.

Breaks ModuleScript in ReplicatedStorage named Config
local Config = {}

Config.StartingCoins = 100
Config.MaxPets = 3

End the module with one return of the table.

Fixed ModuleScript in ReplicatedStorage named Config
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.

Breaks ModuleScript in ReplicatedStorage named Shop
local Shop = {}
local Prices = { Sword = 100 }

return Shop, Prices

Put everything into one table and return that.

Fixed ModuleScript in ReplicatedStorage named Shop
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.

Breaks ModuleScript in ReplicatedStorage named Side
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.

Fixed ModuleScript in ReplicatedStorage named Side
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.

For example: ReplicatedStorage.Config:12: Module code did not return exactly one value

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

  1. Open Output (Window menu, or the Script tab), clear it with Ctrl+K (⌘K on Mac), and press Play.
  2. Find the first red line. It starts with the script's place in the Explorer and the line number, such as ServerScriptService.Shop:12:.
  3. Click the red line. Studio opens that script with the cursor on the failing line.
  4. Read the lines between Stack Begin and Stack End under it: they list the calls that led there, newest first, so you can see which function called the broken one.
  5. 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

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.

More Roblox errors

All Roblox Studio errors

Stop hunting errors line by line.

RoCode reads the scripts in your open place, fixes the error where it happens and tells you what it changed. Free every day, no card required.