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

BrickColor problem with for loops how do i fix this transparency wierd thing?

Asked by 7 years ago
Edited by OldPalHappy 7 years ago

--Ok so I wrote up this script:

Part = script.Parent

while true do
    for i = 0,1,0.1 do
        Part.Transparency = i
        wait(0.01)
    end
    for i = 1,0,-0.1 do
        Part.Transparency = i
        wait(0.01)
    end
    Part.BrickColor = BrickColor.Random()
end

--But it changes when its fully un-transparent, not when it's done with the 2nd for-loop. I know i can just change the brickcolor line to after the 1st for-loop and it would work, but can anyone tell me why it wont change after the 2nd for-loop and changes after the 1st? ( why does it change when its visible and not invisible) Thanks any help would be appreciated

0
I'm confused on the problem. OldPalHappy 1477 — 7y
0
You confused me big time with ur issue. I haven't a clue what the issue is here because you literally contradicted yourself. At first you said it changes when it's completely un transparent which means it changes after the 2nd for loop(Which it should) and, towards the end you said it changes after the 1st for loop... KingLoneCat 2642 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Part = script.Parent

while true do
    for i = 0,1,0.1 do
        Part.Transparency = i
        wait(0.01)
    end
    Part.BrickColor = BrickColor.Random() --the for loops have to finish before the brick color change happen
    for i = 1,0,-0.1 do
        Part.Transparency = i
        wait(0.01)
    end
    Part.BrickColor = BrickColor.Random()
end
Ad

Answer this question