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

Why is my ModuleScript function timing out?

Asked by
Benbebop 1049 Moderation Voter
4 years ago

Repost cause the previous question got no anwers.

01function Window.render(Buffer)
02    if Buffer == nil then
03        Window.getWidth()
04        Window.getHeight()
05        for i=1,Window.Width + Window.Height do
06            local Pixel = Instance.new("Frame")
07            Pixel.Size = UDim2.new(0, 1, 0, 1)
08            Pixel.BorderSizePixel = 0
09            Pixel.Position = UDim2.new(0, i-(i*math.floor(i/Window.Width)), 0, math.floor(i/Window.Width))
10            Pixel.BackgroundColor3 = Color3.new(0, 0, 0)
11            Pixel.Parent = Window.getInstance()
12        end
13    else
14        for i=1,#Buffer do
15            local Pixel = Instance.new("Frame")
View all 39 lines...

Excerpt of the whole script

The script times out on line 4, not line 3 though despite the fact they are basically the same thing. This is being called from a LocalScript.

Also I'm 90% sure I'm returning stuff wrong since ive never really used ModuleScripts before. If it is wrong please let me know.

0
Ask this at the devforum, they will definitely answer you. User#32819 0 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
1for i=1,#Buffer do wait()
2    local Pixel = Instance.new("Frame")
3    Pixel.Size = UDim2.new(0, 1, 0, 1)
4    Pixel.BorderSizePixel = 0
5    Pixel.Position = UDim2.new(0, Buffer[i]["Index"].X, 0, Buffer[i]["Index"].Y)
6    Pixel.BackgroundColor3 = Buffer[i]["Color"]
7    Pixel.Parent = Window.getInstance()

i added wait try this now

0
i just noticed there is a low chance you will see this answer spectacularnicknack 2 — 4y
Ad

Answer this question