Error when trying to use Instance.new

Tell me the resolution of the image like 20 pixels by 20 pixels then we can go from there and then make a color array for each cube.

1 Like

I was able to fix it. Here is the end result. https://i.imgur.com/R9ol11P.png

This is what my program looks like. https://i.imgur.com/9THlkt3.png

1 Like

You really should change it to a loop and just have an array for colors and pixel size x pixel size.

1 Like

Yeah Iā€™ll reprogram it later to do that.

1 Like

Yeah. The issue here is an excess of local variables, not Instance.new. Thereā€™s a 200 local variable limit if I recall correctly. A few optimisations have already been recommended above, so I wonā€™t repeat them.

1 Like

Really? You have any more information on this?

Iā€™ve been programming for almost 10 years now and Iā€™ve never came across a 200 local variable limit. That being said. :thinking: Iā€™m not sure if I even reached 200 before.

1 Like

I donā€™t quite have any information, but you can test for this yourself.

Spam this in your code around 41 or more times:

local a = 1
local a = 1
local a = 1
local a = 1
local a = 1

And you get:

Not quite the same error as the OP but I have a feeling like theyā€™re related. The original code absolutely abuses and hard codes a colossal amount of local variables.

The local variable limit is imposed by the Lua VM.

Whole discussion you can follow from some years ago:

2 Likes