ATransparency = ChoiceA.BackgroundTransparency BTransparency = ChoiceB.BackgroundTransparency while BlackScreen.BackgroundColor3 < Color3.new(5, 5, 5) do for i = 1, 10 do wait(0) ATransparency = ATransparency - 0.1 end for i = 1, 10 do wait(0) BTransparency = BTransparency - 0.1 end end
When BlackScreen.BackgroundColor3 < Color3.new(5, 5, 5)
,
ChoiceA and ChoiceB's BackgroundTransparency should minus 0.1, 10 times every 0 seconds.
When the BlackScreen.BackgroundTransparency was equal to Color3.new(2, 2, 2)
which is less then Color3.new(5, 5, 5)
, it didn't cause ChoiceA and ChoiceB BackgroundTransparency to minus 0.1, 10 times, every 0 seconds.
I don't know what the problem is with this script
when BlackScreen's BackgroundColor3 is less then 5, 5, 5 ChoiceA and ChoiceB BackgroundTransparency should minus 0.1, 10 times, every 0 seconds, and eventually get to 0.
I tested it, and when BlackScreen's BackgroundColor3 was less than 5, 5, 5, ChoiceA and ChoiceB's BackgroundTransparency didn't minus 0.1, 10 times, every 0 seconds.
What is the problem in this script?
ATransparency = ChoiceA.BackgroundTransparency BTransparency = ChoiceB.BackgroundTransparency while BlackScreen.BackgroundColor3 < Color3.new(5, 5, 5) do for i = 1, 10 do wait(0) ATransparency = ATransparency - 0.1 end for i = 1, 10 do wait(0) BTransparency = BTransparency - 0.1 end end
Check out the API for Color3 -- specifically, its values range from 0 to 1. The alternative is to use fromRGB
which uses integers from 0 to 255. Also note that you cannot compare colors like you are doing in your while loop -- you can, compare their individual elements (ex color1.r < color2.r and color1.g < color2.g and color1.b < color2.b
Also note that ATransparency = ChoiceA.BackgroundTransparency
saves the current BackgroundTransparency to ATransparency; when you change ATransparency later, it won't impact ChoiceA
at all. You need to assign to ChoiceA.BackgroundTransparency
to make a difference there.
Minor note: wait(0)
is the same as wait()
Also, you might want to use only one for loop -- otherwise, the BackgroundTransparency will decrease for ChoiceA and then, when it's done, the BackgroundTransparency for ChoiceB will decrease. (If that's what you want then that's fine.)