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

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

Asked by 6 years ago
Edited 6 years ago

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
0
I've had a similar question to this and was fixed easily. User#18043 95 — 6y

2 answers

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

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
0
It tells me in the output that "Face" isn't a valid member of TextBox . Why does it say this ? 1Messi3903 -5 — 6y
0
That means that your path is incorrect. Is "Face" inside of the same object as your script is? call23re2 87 — 6y
0
No it isn't. How do I get face in there? 1Messi3903 -5 — 6y
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. call23re2 87 — 6y
View all comments (2 more)
1
Thank you it worked ! 1Messi3903 -5 — 6y
0
Really, 1Messi? "Face" isn't there and you ask for a path? Is it that hard to figure a basic task? User#18043 95 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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

0
It still doesn't change colors. Any reason why it still doesn't ? 1Messi3903 -5 — 6y
0
In the output it is saying that "face" isnt a valid member of the text box. 1Messi3903 -5 — 6y

Answer this question