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

How to make text on a gui change color like a rainbow ?

I have this script that doesnt work for my text gui. Please help me.

while true do 
script.Parent.Face.Contents.TextColor3 = Color3.new(0,204,255)
wait(.1) 
script.Parent.Face.Contents.TextColor3 = Color3.new(0,255,0)
wait(.1)
script.Parent.Face.Contents.TextColor3 = Color3.new(255,255,0)
wait(.1)
script.Parent.Face.Contents.TextColor3 = Color3.new(255,0,0)
wait(.1)
script.Parent.Face.Contents.TextColor3 = Color3.new(153,0,153)
wait(.1)
script.Parent.Face.Contents.TextColor3 = Color3.new(0,0,255)
wait(.1)
end

1 comment

0

I've had a similar question to this and was fixed easily.

2 answers

✓ Accepted answer

Like NoBootAvailable said, you should be using Color3.fromRGB rather than Color3.new. If you're still having a problem, make sure that the gui element you're working with is visible and that your path to the gui element is correct.

To make a few improvements, if you only wanted to use a specific set of colors you can create a table and use a for loop to set the colors.

local colors = {Color3.fromRGB(0, 204, 205), Color3.fromRGB(0, 255, 0)} -- You can continue to add colors here.

while true do
	for index, color in pairs(colors) do
		script.Parent.Face.Contents.TextColor3 = color
		wait(0.1)
	end
end

The last approach would blink between colors. Assuming you're trying to create a smoother rainbow effect this may work better. Here I'm using fromHSV rather than Color3. fromHSV parameters include a hue value, making it easier to create a rainbow effect.

while true do
	for i = 0,1,0.01 do
		script.Parent.Face.Contents.TextColor3 = Color3.fromHSV(i,1,1)
		wait(0.1)
	end
end

6 comments

0

It tells me in the output that "Face" isn't a valid member of TextBox . Why does it say this ?

0

That means that your path is incorrect. Is "Face" inside of the same object as your script is?

0

No it isn't. How do I get face in there?

0

You should change your path so that it leads to where "Face" actually is, or you can move the script so that it has the same parent as "Face" does.

1

Thank you it worked !

0

Really, 1Messi? "Face" isn't there and you ask for a path? Is it that hard to figure a basic task?

When handling double or triple digits for Color3, use Color3:fromRGB().

while true do 
	local num = math.random(0, 255) -- This will pick a random number in a range from 0 to	255.
	script.Parent.Face.Contents.TextColor3 = Color3.fromRGB(num, num, num)
	wait(.1)
end

2 comments

0

It still doesn't change colors. Any reason why it still doesn't ?

0

In the output it is saying that "face" isnt a valid member of the text box.

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