Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

For i loop randomly stopping, can someone explain why?

Asked by 3 years ago

ok so I have a bunch of data in a Lua table and im trying to loop through it. it stops once i reaches 62 for some reason.

code (sorry if messy):

--  i printed width * height and i think its 6000 but definitely not 62
local lt = 1
local count = 0
for i = 1, width * height do
    local v = data.pixelData[tostring(i)]
    local pixelData = v
    local x = pixelData.pixelLocation.x or 0
    local y = pixelData.pixelLocation.y or 0
    local part = Instance.new('Frame', surf)
    part.Size = UDim2.new(0,1*divide,0,1*divide)
    --part.ZIndex = 1000
    --part.Enabled = false
    --part.BorderSizePixel = 0
    --part.Position = UDim2.new(0, (x*divide)-(1*divide), 0, -((y*divide)-(1*divide)))
    part.Position = UDim2.new(0, (x*divide)-(1*divide), 0, (y*divide)-(1*divide))
    part.BackgroundColor3 = Color3.fromRGB(pixelData.pixelRgb.r, pixelData.pixelRgb.g, pixelData.pixelRgb.b)
    part.Name = "pixel"..pixelData.pixelId
    lt += 1;
    count += 1;
    print(count, " / " ..i)
    if lt > 25 then
    -- Make sure it won't freeze
    wait(0.1)
    lt = 0
    end
end

Answer this question