In short
A table written with curly brackets, such as { Sword = 10, Bow = 20 }, needs a comma (or a semicolon) between its entries. Luau finished one entry and found the start of the next with nothing between them. The line in the message is the entry after the missing comma, so add the comma at the end of the line above it.
What the message means
ReplicatedStorage.ShopItems:4: Expected ',' after table constructor element
It is a syntax error, so the script or ModuleScript does not run at all, and every script that requires that module fails too, usually with Requested module experienced an error while loading.
A comma after the last entry is allowed, so the easiest habit is to end every line of a table with a comma.
Causes and fixes
Three things cause this error in practice. Each one below has the smallest code that triggers it, then the fix.
- A comma is missing at the end of a line
- No comma after a function or before a comment
- Entries with [keys] written side by side
A comma is missing at the end of a line
Settings and item lists are often written one entry per line, and adding a line at the end is easy to do without adding the comma to the line before it.
local ShopItems = {
Sword = 100,
Shield = 150
Bow = 200,
}
return ShopItems
Add the comma at the end of the line before the one in the message. Ending every entry with a comma, the last one included, stops it happening again.
local ShopItems = {
Sword = 100,
Shield = 150,
Bow = 200,
}
return ShopItems
No comma after a function or before a comment
A function inside a table ends with end, which does not look like it needs a comma, but it does. A comment at the end of a line also hides where the comma should go: it goes before the --.
local Buttons = {
onBuy = function()
print("bought")
end
price = 25 -- coins
color = "Green"
}
return Buttons
Put a comma after the end of the function, and before any comment.
local Buttons = {
onBuy = function()
print("bought")
end,
price = 25, -- coins
color = "Green",
}
return Buttons
Entries with [keys] written side by side
Keys in square brackets, such as [1] or ["Red Team"], follow the same rule: one comma between each entry, even on one line.
local TeamColors = { ["Red Team"] = "Really red" ["Blue Team"] = "Really blue" }
return TeamColors
Add the comma between the entries.
local TeamColors = {
["Red Team"] = "Really red",
["Blue Team"] = "Really blue",
}
return TeamColors
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.
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
- A syntax error stops the whole script before its first line runs, so nothing in that script works, not just the broken line.
- Open the script. The Script Editor underlines the problem in red; hover over the underline to read the message.
- Open Script Analysis (View tab) to see every syntax error in every script, with its line number. Double-click one to jump to it.
- 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
Can a Luau table end with a comma?
Yes. { 1, 2, 3, } is valid, and ending every line with a comma makes adding entries safe.
Can I use semicolons in a table?
Yes, ; works as a separator too: { a = 1; b = 2 }. Most Roblox code uses commas.
Why does a list of plain values give a different error?
In a list like { "a" "b" }, Luau may report Expected '}' (to close '{' ...) instead. The fix is the same: add the missing comma.
Can RoCode fix it?
Yes. Paste the Output line into RoCode. It reads the module in your open place and adds the missing commas.
Sources and further reading
- Luau: syntax. table constructors
- Roblox Creator Docs: tables. arrays and dictionaries
How the code was checked: every block marked Fixed passes Luau's strict type checker against Roblox's API definitions (luau-lsp, 5 November 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 5 November 2026. A type check catches misspelt APIs and wrong types, not game logic, so playtest in Studio before you publish.