Roblox Studio syntax error

Incomplete statement: expected assignment or a function call

What Incomplete statement: expected assignment or a function call 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 readSyntax errorLuau

In short

Every line in Luau has to do something: set a variable (x = 5) or call a function (print(x)). A line that only works out a value, such as coins + 10 or part.Anchored on its own, does nothing, so Luau rejects it. Store the result with =, or add the () the call is missing.

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.Coins:7: Incomplete statement: expected assignment or a function call

Other languages let a bare value sit on a line. Luau does not, which catches real mistakes: a forgotten =, a == that should be =, or a method name typed without its brackets.

Like every syntax error, it stops the whole script until it is fixed.

Causes and fixes

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

A calculation is not stored anywhere

coins + 10 works out a number and throws it away. Luau treats that as a mistake.

Breaks Script in ServerScriptService named Coins
local coins = 0

coins + 10
print(coins)

Assign the result: coins = coins + 10, or the short form coins += 10.

Fixed Script in ServerScriptService named Coins
local coins = 0

coins += 10
print(coins)

== used where = was meant

part.Anchored == true compares and gives back true or false; it does not set anything. On a line of its own it is an incomplete statement.

Breaks Script in ServerScriptService named Spawner
local part = Instance.new("Part")
part.Anchored == true
part.Parent = workspace

Use a single = to set a property or variable.

Fixed Script in ServerScriptService named Spawner
local part = Instance.new("Part")
part.Anchored = true
part.Parent = workspace

A method or function name without ()

part:Destroy or print on their own name the function but do not call it.

Breaks Script in ServerScriptService named Cleanup
local part = workspace:WaitForChild("OldWall")
part.Destroy

Call it with brackets, and a colon for methods on Roblox objects: part:Destroy().

Fixed Script in ServerScriptService named Cleanup
local part = workspace:WaitForChild("OldWall")
part:Destroy()

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.Coins:7: Incomplete statement: expected assignment or a function call

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. A syntax error stops the whole script before its first line runs, so nothing in that script works, not just the broken line.
  2. Open the script. The Script Editor underlines the problem in red; hover over the underline to read the message.
  3. Open Script Analysis (View tab) to see every syntax error in every script, with its line number. Double-click one to jump to it.
  4. The line number in the message is where Luau gave up, which is often below the real mistake. The (to close ... at line N) part points at the line where the unclosed bracket or block starts.

Questions

Why can a value not be on its own line?

Luau only allows statements that do something: an assignment or a call. A value on its own would be thrown away, so it is almost always a mistake, and Luau says so.

What is the difference between = and ==?

= sets: coins = 10. == compares: if coins == 10 then.

Why part:Destroy() and not part.Destroy()?

Methods on Roblox objects are called with a colon, which passes the object itself. part.Destroy() would call it with nothing to destroy and fail at runtime.

Can RoCode fix it?

Yes. Paste the Output line into RoCode. It finds the line in the script in your open place and turns it into the assignment or call you meant.

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 only to fail with the message on this page. The message wording was checked by compiling each broken block on this page with luau-compile, which uses the same Luau parser as Roblox Studio, and against the message strings in Roblox Studio itself 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.