Think 'Malformed Pattern'

I’m getting spammed this error in my console on the Think function:

ERROR: GAMEMODE:'Think' Failed: TestScript1\gamemode\cl_think.lua:128: malformed pattern (missing ']')

The line that is causing it is:
elseif( string.find( ChatVGUI.TextEntry:GetValue(), “[[” ) ) then

It thinks I’m missing a ‘]’ but I’m not trying to do any pattern of any sort. Is there a way around this?

Use the [ escape code to generate a [ instead.

elseif( string.find( ChatVGUI.TextEntry:GetValue(), "\[\[" ) ) then

I still seem to be getting the error, that didn’t help/do anything.

What is this check being used for?

It prints in the console if the person has that value/string in their chat.

Are you checking for the characters so that you can remove them?

If so, use something like this:

local BadChars = {"[", "%"}

function string.escape(str)
	local rstr = ""
	for k in (string.gmatch(str, ".")) do
		for x, y in pairs(BadChars) do
			if (y == k) then
				k = ""
		rstr = rstr..k
	return rstr


Yes, that should work.

string.find( ChatVGUI.TextEntry:GetValue(), “[[”, 1, true )
Why overcomplicate things?