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
3 years ago

Repost cause the previous question got no anwers.

function Window.render(Buffer)
    if Buffer == nil then
        Window.getWidth()
        Window.getHeight()
        for i=1,Window.Width + Window.Height do
            local Pixel = Instance.new("Frame")
            Pixel.Size = UDim2.new(0, 1, 0, 1)
            Pixel.BorderSizePixel = 0
            Pixel.Position = UDim2.new(0, i-(i*math.floor(i/Window.Width)), 0, math.floor(i/Window.Width))
            Pixel.BackgroundColor3 = Color3.new(0, 0, 0)
            Pixel.Parent = Window.getInstance()
        end
    else
        for i=1,#Buffer do
            local Pixel = Instance.new("Frame")
            Pixel.Size = UDim2.new(0, 1, 0, 1)
            Pixel.BorderSizePixel = 0
            Pixel.Position = UDim2.new(0, Buffer[i]["Index"].X, 0, Buffer[i]["Index"].Y)
            Pixel.BackgroundColor3 = Buffer[i]["Color"]
            Pixel.Parent = Window.getInstance()
        end
    end 
end

function Window.isCloseRequested()

end

function Window.getWidth()
    Window.Width = game.Players.LocalPlayer.PlayerGui.Render.Frame.AbsoluteSize.X
end

function Window.getHeight()
    Window.Height = game.Players.LocalPlayer.PlayerGui.Render.Frame.AbsoluteSize.Y
end

function Window.getInstance()
    Window.Instance = game.Players.LocalPlayer.PlayerGui.Render.Frame
end

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 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
for i=1,#Buffer do wait()
    local Pixel = Instance.new("Frame")
    Pixel.Size = UDim2.new(0, 1, 0, 1)
    Pixel.BorderSizePixel = 0
    Pixel.Position = UDim2.new(0, Buffer[i]["Index"].X, 0, Buffer[i]["Index"].Y)
    Pixel.BackgroundColor3 = Buffer[i]["Color"]
    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 — 3y
Ad

Answer this question