Expected ')' to close '(' at column 23), got 'then'

The error I am getting doesn’t make any sense, as there is no ( on line 319. I am quite confused.


It was a bug on roblox’s end, after an hour or so it resolved itself (was an invisible bug).

Is there a end statement after this condition?

Yep. Here’s the whole function, mb for not posting originally.

game.Players.PlayerAdded:Connect(function(player)
	checkBlacklist(player)
	checkDayban(player)
	player.Chatted:Connect(function(message, recipient)
		local msg = string.lower(message)
		local preArgs = msg:split(" ")		
		local preCommand = preArgs[1]
		local cmd = preCommand:split(prefix)
		cmd = cmd[2]

		if commands[cmd] then
			local args = {}

			for i = 2, #preArgs do
				table.insert(args, preArgs[i])
			end

			if (cmd == "apply") then
				commands[cmd](player, args)
			elseif (cmd == "sm") then
				commands[cmd](player, message:split(" ")[1]:split(prefix)[2])
			elseif (getAdmin(player)) then
				commands[cmd](player, args)
			end
		end
	end)	
end)

You forgot to close a line in your script, I can’t tell you where the exact line is that you’re not closing because I’m not seeing the entire script, try to figure out which “if statment” or “function” misses an “end”.

Not gonna lie, I didn’t find it either, can you undo (Ctrl + Z) the last edit you did? and then redo (Ctrl + LShift + Z) so you can see if the are missing an “end” or “)”?

I wrote like 100 lines of code before testing :sob:

YO i just reopened my game and the error went away lmao

LOL, if the error appears again, try copying and pasting the code in any writing app, then undo to see what’s going on in the code, after that if you lost your code paste the code you have pasted in your app and try again. Good luck!

There’s a developer tool at the top of your screen when you’re editing a script that says “Go to Error”, click on it and it should bring you to the line of code with the error. Hope this helps!

I’m pretty sure that’s a bug on roblox’s end. It happened to me a few times, basically a non existant error appears, I think it has something to do with the script using outdated code even though you can’t see it. A way to fix it is to insert some random code, exit the script and then undo that code and exit the script.

Yep it was a roblox bug… it fixed itself after an hour

or just press Reload Script on the top in the script editor tab on the right

1 Like