It doesn’t produce anything, because of the error I posted.
local IMG2RBX = Instance.new("ScreenGui",game.Players.LocalPlayer.PlayerGui)
for i = 1, 256 do
local newFrame = Instance.new("Frame", IMG2RBX);
newFrame.BorderSizePixel = 0;
newFrame.BackgroundColor3 = Color3.fromRGB(255,255,255);
newFrame.Size = UDim2.new(0,1,0,1);
newFrame.Position = UDim2.new(0, 0, 0, 0);
wait()
end
You have too much local variables. Use a for loop.
I would of never guessed that. I’ll try that, thanks.
You still need to edit the position and color.
Hence why i’m trying to ask you what it’s supposed to look like.
I get the color and position automatically by each pixel in the image. My C# code handles that.
Oh ok, so pull that data from the array for each frame then put it into the pos/color in the loop.
Yep, that’s what I’ve been doing. You can see it in the code I posted
Do you need help setting up the array or figuring out how to connect it in the loop?
Wait there is a problem. I need to create a new frame for every pixel in the image… I don’t see how I can dynamically change the position and color when it’s in a for loop like posted above.
Get an array with color/pos and tie it into the loop.
Use the key for the tile layout.
Maybe a function will work? function creates local frame, returns it, then the code sets the properties
Function or no function, works the same way. You’ll need to make an array.
PosAndColor = {
{colorvalue, posvalue},
{colorvalue, posvalue},
{colorvalue, posvalue},
}
If the positions just make a shape you can use math to get rid of that issue or use a UIGridLayout and number the order they go in based off the key of the main array; however, the gridlayout can mess up the image.
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.
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
You really should change it to a loop and just have an array for colors and pixel size x pixel size.
Yeah I’ll reprogram it later to do that.
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.
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. I’m not sure if I even reached 200 before.
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: