Roblox Studio error

Requested module experienced an error while loading

What Requested module experienced an error while loading means in Roblox Studio, the three things that cause it with the code that triggers each, and the fix for each one.

Updated 23 October 20263 min readErrorLuau

In short

This message is a pointer, not the real error. It says the ModuleScript you passed to require crashed while it was running its top-level code. The real error is printed just above it in Output, with the module's own name and line. Fix that one and this message goes away. Two related messages: Module code did not return exactly one value (the module has no return at the end) and Requested module was required recursively (two modules require each other).

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)
ServerScriptService.Main:3: Requested module experienced an error while loading

Other forms of the same message:

  • Module code did not return exactly one value
  • Requested module was required recursively

require runs the module once, the first time, and keeps what it returns. If that first run errors, every script that requires it gets this message, and each require of it fails the same way.

The line number in this message is the require line in your script, not the problem. The problem is in the module.

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 its own error

Any runtime error in the module's top-level code (outside its functions) breaks the load: a WaitForChild on the wrong side, a nil index, a typo.

Breaks ModuleScript in ReplicatedStorage named Config
local Config = {}

-- top-level code runs when the module is required;
-- if Settings is missing: attempt to index nil with 'GetAttribute',
-- and the script that required it gets:
-- Requested module experienced an error while loading
local settingsFolder = script.Parent:FindFirstChild("Settings")
Config.MaxPlayers = settingsFolder:GetAttribute("MaxPlayers")

return Config

Read the error just above in Output, which names the module and its line, and fix that. Keep top-level module code small and safe; do risky work inside functions that callers run later.

Fixed ModuleScript in ReplicatedStorage named Config
local Config = {}

local parent = script.Parent
local settingsFolder = parent and parent:FindFirstChild("Settings")
local maxPlayers = settingsFolder and settingsFolder:GetAttribute("MaxPlayers")
Config.MaxPlayers = if typeof(maxPlayers) == "number" then maxPlayers else 8

return Config

The module does not return exactly one value

A ModuleScript must end with return and one value (usually a table). A missing return gives Module code did not return exactly one value.

Breaks ModuleScript in ReplicatedStorage named Shop
local Shop = {}

function Shop.price(itemName)
	return if itemName == "Sword" then 100 else 50
end

-- forgot: return Shop

End the module with return and the table.

Fixed ModuleScript in ReplicatedStorage named Shop
local Shop = {}

function Shop.price(itemName: string): number
	return if itemName == "Sword" then 100 else 50
end

return Shop

Two modules require each other

If module A requires B at its top and B requires A at its top, neither can finish loading first. Roblox stops with Requested module was required recursively.

Breaks ModuleScript in ReplicatedStorage named Inventory
-- ModuleScript Inventory, in ReplicatedStorage:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Shop = require(ReplicatedStorage:WaitForChild("Shop")) -- Shop also requires Inventory

local Inventory = {}
function Inventory.add(itemName)
	print("added", itemName, Shop)
end
return Inventory

Break the loop: move what both need into a third module, or require the other module inside the function that uses it, so it loads only when called.

Fixed ModuleScript in ReplicatedStorage named Inventory
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Inventory = {}

function Inventory.add(itemName: string)
	-- required on first use, after both modules have finished loading
	local Shop = require(ReplicatedStorage:WaitForChild("Shop")) :: any
	print("added", itemName, Shop)
end

return Inventory

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: ServerScriptService.Main:3: Requested module experienced an error while loading

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. Clear Output (Ctrl+K), press Play, and scroll up from this message to the first red line before it. That line names the ModuleScript and the line inside it that failed.
  2. Click that earlier line to open the module at the problem.
  3. If there is no earlier line, the module did not return a value or there is a require loop: check that every ModuleScript ends with return, and that no two modules require each other at the top.

Questions

Where is the real error?

Just above this message in Output. It names the ModuleScript and the line inside it. This message is only the script that called require reporting that the load failed.

Why does every script that requires the module fail?

Because the module could not finish loading, so none of them get its value. Fix the module once and all of them work.

Can a module return a function instead of a table?

Yes, any single value works. What fails is returning nothing, or more than one value.

Can RoCode fix it?

Yes. Paste the Output lines into RoCode, including the one above this message. It opens the module in your open place, fixes its error or its return, and untangles require loops.

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, 23 October 2026), and every block marked Breaks compiles and fails only when it runs. The message wording was checked against the message strings in Roblox Studio itself (macOS build of 13 October 2026) on 23 October 2026. A type check catches misspelt APIs and wrong types, not game logic, so playtest in Studio before you publish.

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.