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

How do I change transparency all at once?

Asked by
B080 19
7 years ago
Edited 7 years ago

I have this:

for i,v in pairs (text) do
    for i = 1,40 do
        wait()
        if (v:IsA("Frame")) then
            v.BackgroundTransparency = v.BackgroundTransparency + 1/40
        elseif (v:IsA("TextLabel")) then
            v.TextTransparency = v.TextTransparency + 1/40
        end
    end
end

This makes the objects fade one at a time, but I want all of the objects to fade at the same time.

How would I go about doing this?

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
7 years ago

Nice attempt at your code. The solution is very simple. Your current code starts off with the generic for loop, which iterates through all descendants of the specified table, performing an action for each item there. You have the numeric for loop INSIDE of the generic, however, it needs to be OUTSIDE of it for all Frames to change at the same time.

for i = 1,40 do
    for _,v in pairs (text) do -- I had to change the index, which you set to "i", as it would interfere with the numeric for loop.
        wait()
        if (v:IsA("Frame")) then
            v.BackgroundTransparency = v.BackgroundTransparency + 1/40
        elseif (v:IsA("TextLabel")) then
            v.TextTransparency = v.TextTransparency + 1/40
        end
    end
end

Ad

Answer this question