This can happen with too many if statements are nested into one if statement.
Control structure too long near
Too many elseif statements in one if control structure can cause the same error.
if X then
-- stuff
elseif Y then
-- stuff
elseif Z then
-- stuff
end
Source:
https://forums.wowace.com/showthread.php?t=21768
It can happen with a loop too.
local b="x=1;"
while true do
local s="while true do "..b.." end"
local f,err=loadstring(s)
print(#b)
if f==nil then
print(#b,err)
break
end
b=b..b
end
Source:
http://lua.2524044.n2.nabble.com/Cause-for-quot-control-structure-too-long-quot-td7650425.html
If you reach this kind of limit, there is something really wrong with your code.
I fixed it, so nothing is wrong with my script.