Roblox Studio syntax error

Expected identifier when parsing expression, got ')'

What Expected identifier when parsing expression, got ')' 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

An expression is anything that gives a value: a name, a number, a string, a call. This error means Luau was in the middle of reading one, for example right after =, +, .. or a comma, and found something that cannot start a value: the word after got. Look just before that word on the line: a value is missing there, or there is a symbol too many.

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.Shop:6: Expected identifier when parsing expression, got ')'

Other forms of the same message:

  • Expected identifier when parsing expression, got 'local'
  • Expected identifier when parsing expression, got '='
  • Expected identifier when parsing expression, got 'then'

got ')' usually means a value is missing before a closing bracket, like print("Hi " .. ). got 'local' means a line ended without its value, like local x =. got 'then' together with an earlier Expected 'then' means = was used where == belongs.

Luau may print several syntax errors for one mistake. Fix the first one and compile again; the rest often disappear.

Causes and fixes

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

A value is missing after an operator or =

Half-finished lines: local speed = with nothing after it, or "Coins: " .. with the variable left out.

Breaks Script in ServerScriptService named Shop
local label = "Coins: " ..
local speed = 16

Finish the expression with the value you meant.

Fixed Script in ServerScriptService named Shop
local coins = 25
local label = "Coins: " .. coins
local speed = 16
print(label, speed)

= instead of == in a condition

= sets a variable; == compares. In an if, a single = gives Expected 'then' when parsing if statement, got '=' first, followed by this message.

Breaks Script in ServerScriptService named Shop
local coins = 100

if coins = 100 then
	print("exactly 100")
end

Use == to compare (and ~= for "not equal").

Fixed Script in ServerScriptService named Shop
local coins = 100

if coins == 100 then
	print("exactly 100")
end

end) after a function that is not inside a call

end) belongs to Connect(function() ... end). After a plain local function, Luau reads the ) as the start of something new and finds no value in it. A doubled )) at the end of a call fails the same way.

Breaks Script in a Part in Workspace named Pad
local function onTouched(hit)
	print(hit.Name)
end)

Use plain end for a plain function, then connect it by name.

Fixed Script in a Part in Workspace named Pad
local pad = script.Parent :: BasePart

local function onTouched(hit: BasePart)
	print(hit.Name)
end

pad.Touched:Connect(onTouched)

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.Shop:6: Expected identifier when parsing expression, got ')'

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

What is an identifier?

A name, such as a variable or function name. The message says identifier, but anything that gives a value would do: a number, a string, a call, a table.

Why do I get several errors for one line?

After the first mistake, Luau tries to keep reading and trips over the rest of the line. Fix the first error in the list and the others often go away.

How do I compare in an if?

With == (equal) or ~= (not equal). A single = only sets a variable and is not allowed in a condition.

Can RoCode fix it?

Yes. Paste the Output line into RoCode. It finds the broken line in the script in your open place and completes or corrects the expression.

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, 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.