Roblox Studio error

Argument 1 missing or nil

What Argument 1 missing or nil 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

A Roblox engine function (a method on an Instance or a service) needs a value in that position and got nil or nothing. Argument 1 is the first value inside the brackets. Look at that argument on the failing line, find out why it is nil (usually a variable or attribute that was never set, or a value a client did not send), and check it before the call.

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.Spawner:6: Argument 1 missing or nil

Other forms of the same message:

  • Argument 2 missing or nil
  • Argument 3 missing or nil

Built-in Luau functions word the same mistake as invalid argument #1 to 'x' (table expected, got nil). Roblox's own functions say Argument N missing or nil.

For a method called with a colon, such as folder:FindFirstChild(name), argument 1 is name: the object before the colon is not counted.

Causes and fixes

Three things cause this error in practice. Each one below has the smallest code that triggers it, then the fix.

The value you passed was never set

A variable, attribute or table entry that was never set is nil. Passing it on to a Roblox method that needs a value, such as the name in FindFirstChild, fails on that call rather than where the value went missing.

Breaks Script in ServerScriptService named Teleporter
local button = workspace:WaitForChild("TeleportButton")
local targets = workspace:WaitForChild("Targets")

-- the button has no "Target" attribute, so this is nil:
-- Argument 1 missing or nil
local target = targets:FindFirstChild(button:GetAttribute("Target"))
print(target)

Read the value into a variable, check it, and only then pass it on. Set the attribute in the Properties window (Attributes, then +).

Fixed Script in ServerScriptService named Teleporter
local button = workspace:WaitForChild("TeleportButton")
local targets = workspace:WaitForChild("Targets")

local targetName = button:GetAttribute("Target")
if typeof(targetName) ~= "string" then
	warn("[Teleporter] TeleportButton has no Target attribute")
	return
end
local target = targets:FindFirstChild(targetName)
print(target)

The argument was left out

Some calls need a value that is easy to forget, such as the name in FindFirstChild() or the class in IsA().

Breaks Script in ServerScriptService named Spawner
local folder = workspace:WaitForChild("Enemies")

-- no name given: Argument 1 missing or nil
local boss = folder:FindFirstChild()
print(boss)

Pass every value the function needs. Each method's page in the Creator Docs lists its parameters; the ones without a default are required.

Fixed Script in ServerScriptService named Spawner
local folder = workspace:WaitForChild("Enemies")

local boss = folder:FindFirstChild("Boss")
print(boss)

A RemoteEvent value arrived as nil

A client can fire a RemoteEvent with fewer values than the server expects (or with an Instance the server cannot see, which arrives as nil). The handler then passes nil into an engine call.

Breaks Script in ServerScriptService named Equip
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local equip = ReplicatedStorage:WaitForChild("Equip")

-- the client called equip:FireServer() with no tool name:
equip.OnServerEvent:Connect(function(player, toolName)
	-- toolName is nil: Argument 1 missing or nil
	local tool = player.Backpack:FindFirstChild(toolName)
	print(tool)
end)

On the server, check every value a client sends: its type, and that it is an object the server knows. Send names or IDs and look the object up on the server instead of trusting the client.

Fixed Script in ServerScriptService named Equip
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local equip = ReplicatedStorage:WaitForChild("Equip") :: RemoteEvent

equip.OnServerEvent:Connect(function(player: Player, toolName: unknown)
	if typeof(toolName) ~= "string" then
		return
	end
	local backpack = player:FindFirstChildOfClass("Backpack")
	local tool = backpack and backpack:FindFirstChild(toolName)
	if tool and tool:IsA("Tool") then
		print(player.Name, "has", tool.Name)
	end
end)

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.Spawner:6: Argument 1 missing or nil

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

Which value is argument 1?

The first value inside the brackets of the Roblox call on that line. In targets:FindFirstChild(name) it is name.

How is it different from Unable to cast value to Object?

missing or nil means the value was nil or left out. Unable to cast value to Object means a value was there, but the wrong type.

Why is my RemoteEvent argument nil on the server?

An Instance only travels through a remote if the other side can see it. Objects in ServerStorage, or created by a LocalScript, arrive as nil. Send a name or an ID instead.

Can RoCode fix it?

Yes. Paste the Output line into RoCode. It traces the nil argument back in the script in your open place and adds the check or the missing value.

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.