Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My script isn't working, can anyone help me?

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

7 comments

0

Please edit this post and put your code in a 'code block' (Lua Logo) so we can further help you.

0

How do you put it in a code block?

0

USE A MORE DESCRIPTIVE TITLE!

0

Updated for code blocks.

0

Press the little lua button and put the code inbetween the two "~~~~~" lines

0

I did it

0

You were no help whatsoever M39a9am3R. I doubt you even knew how to help.

1 answer

✓ Accepted answer

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.)

4 comments

0

Thanks, that helped alot!

0

How do you use FromRGB?

0

How do you use FromRGB?

0

ex, a red color would be "Color3.fromRGB(255, 0, 0)". This gives the identical result as to saying "Color3.new(1, 0, 0)"

This discussion is preserved as it was. New answers, comments, and votes are closed.