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

How do I change a TextLabel's color?

Asked by 9 years ago

I tried this:

script.Parent.TextColor3 = 255, 0, 0

I also tried:

script.Parent.TextColor3 = Vector3.new(255, 0, 0)

Any ideas?

1 answer

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

Colors are Color3s. They are constructed with the Color3 constructor, Color.new(r,g,b).

Note that the R, G, and B values are from 0 to 1 as opposed to 0 to 255, so, for example, what the properties tab shows as 192 is actually (approximately) 0.75.


The Wiki would have described this to you:

From TextLabel,

Color3 TextColor3


In a tangentially related note, the first line you indicated is obviously wrong because the comma (,) is used to separate multiple assignments:

one, two = 1, 2

print(one); -- 1
print(two); -- 2

Which would mean you were only assigning the first value (R) to the color and throwing out the other ones.

Ad

Answer this question