Start building

How to Fix "attempt to call a nil value" in Roblox Studio

Roblox Studio OutputRuntime Error
attempt to call a nil value
30-Second Fix

Why it happens & how to fix it

You tried to call a function that does not exist on that object or table. Check spelling/casing (`FindFirstChild`, not `FindFirstchild`), make sure your ModuleScript actually `return`s the function, and check whether you typed `.` instead of `:`.

Broken codeCauses error
-- BROKEN: lowercase method name + function defined too late
part:destroy() -- should be :Destroy()
Working fixSafe Luau
-- FIXED: exact Roblox method casing
part:Destroy()

Root cause & debugging checklist

Luau is case-sensitive. Calling `part:destroy()` (lowercase d) or calling a local function defined BELOW the line that calls it evaluates to `nil()` and throws `attempt to call a nil value`.

  • Check Roblox method capitalization (`Destroy`, `WaitForChild`, `GetService`, `Connect`).
  • Ensure local helper functions are declared ABOVE where you call them.
  • Confirm every ModuleScript ends with `return module`.

Common questions.

Why does a local function defined below throw nil?

In Luau, local variables only come into scope after their declaration line. Declare helper functions before calling them.

More Roblox error fixes.

All 12 error guides

Revix reads Studio Output
and fixes bugs automatically.

Start building free

Free to start. No card needed.