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

Script Setting GUI TextColor3 to 19380, 62985, 65025 instead of 76, 247, 255?

Asked by 8 years ago

Okay so I am having a problem where my script will work at changing the text color to red, but when it tries to change it back to blue it doesn't set it back to blue, it sets it to white. The color code that it gets changed to instead of 76, 247, 255 is 19380, 62985, 65025.

local length = string.len("11223344556677889911223344556677889911223344556677889911223344556");
if length == nil then
    length = 65;
end;

while wait(0.01) do
    if string.len(script.Parent.Text) > length then
        script.Parent.TextColor3 = Color3.new(255, 0, 0);
    else
        script.Parent.TextColor3 = Color3.new(76, 247, 255);
    end;
end;

1 answer

Log in to vote
1
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

Color3 Values that are not 0 or 255 must be divided by 255:

local length = string.len("11223344556677889911223344556677889911223344556677889911223344556");
if length == nil then
    length = 65;
end;

while wait(0.01) do
    if string.len(script.Parent.Text) > length then
        script.Parent.TextColor3 = Color3.new(255, 0, 0);
    else
        script.Parent.TextColor3 = Color3.new(76/255, 247/255, 255);
    end;
end;

2
...all values should be in the range [0,1]. I'm not sure why 255 would work to mean 1. It should be Color3.new(1, 0, 0) BlueTaslem 18071 — 8y
0
It does. Pyrondon 2089 — 8y
0
Thanks. BlueTaslem, the reason it works is because it's saying that 76/255 is a fraction out of 255 where 255 is the denumerator (Bottom of the fraction) and 76 is the numerator (top of the fraction) and 76 divided by 255 is 0.298039216. MrLonely1221 701 — 8y
Ad

Answer this question