Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

:1405: main function has more than 200 local variables?

So I'm working on editing a script and when i try to run it it says : :1405: main function has more than 200 local variables. How do I fix this? P.S. i can't put the script in a code block because of how huge it is

1 comment

0

Can you share a portion of your code? For example, maybe some of where you're defining all your local variables? We can give suggestions on how to cut down the number.

1 answer

Source: http://lua.2524044.n2.nabble.com/main-function-has-more-than-200-local-variables-td3080987.html

Local variables are a limited resource. Due to the structure of the VM bytecode, and a few other things, a function cannot have more than 256 local variables. In practice, the limit is reduced down to 200, though it can probably be raised to 240 or 250 without too many issues. Local variables are intended to be variables though, not named constants. I would suggest either placing the constants into a table, or modifying the parser to accept named constants in a way similar to C's "#define CONSTANT value".

This discussion is preserved as it was. New answers, comments, and votes are closed.