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

why would this get slower?

Asked by 10 years ago

This goes fast at the first but as this function runs it slows down and after I run the function about 2-3 times it gets so slowww... (Its like 2 minutes) Any IdeaS? If you need a little video to explaine "Slow" down https://www.youtube.com/watch?v=xhp6dYovZHE

function Dismiss(plr)
    for _, v in pairs(Tablets) do
        if v.Plr == plr.Name then
            for i = 0, 1, 0.1 do
                wait(0.01)
                v.Tab.Transparency = i
                v.Box.Transparency = i
                if i==1 then 
                break
                end
            end
            v.Tab:Remove()
            break
        end
    end
end

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

You should use good style. Spaces and tabs make it much more readable.

Your use of the if is probably not what you wanted. You probably wanted this:

function Dismiss(plr)
    for _, v in pairs(Tablets) do
        if v.Plr == plr.Name then
            for i = 0, 1, 0.1 do
                wait(0.01)
                v.Tab.Transparency = i
                v.Box.Transparency = i
            end
            v.Tab:Remove()
            break
        end
    end
end

Why it would be slow? I am not sure.

Most likely there is another problem. This doesn't change anything that would require more work to do anything. One concern is that it eliminates a portion of v but does not remove v from the list of Tablets.

Ad

Answer this question