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

Changing a TextLabel's Text Color? [Solved]

Asked by 10 years ago

I'm trying to have a tooltip script that displays a player's name in a GUI when another player hover's their mouse over them, and have red text when it's an enemy player, but apparently Color3.new() doesn't work for TextColor3. So, does anyone know how this line should be rewritten?:

TextLabel.TextColor3 = Color3.new(255, 254, 205)

2 answers

Log in to vote
2
Answered by 10 years ago

You would use Color3.new, but the R, G, and B values in Color3.new range from 0 - 1. Basically, you would write your code like this:

TextLabel.TextColor3 = Color3.new(255/255, 254/255,205/255) --It's dividing the numbers by 255 to scale the value to a number between 0 and 1
0
Huh, that's misleading of them... Never would have realized that the values had to be within a range of 0-1 deaththerapy 60 — 10y
0
Yeah I know it's weird TurboFusion 1821 — 10y
0
It's not within a range of 0-1. It's 0-255 :P OniiCh_n 410 — 10y
0
zMatrix65831, in case you do not know, scripts read Color3 as 0-1. coo1o 227 — 10y
Ad
Log in to vote
2
Answered by
Ekkoh 635 Moderation Voter
10 years ago

If you have a lot of Color3 values you need to put in your code, you can paste this code at the top of your script to be able to use a 0-255 range.

local _Color3 = Color3
local Color3 = { new = function(r, g, b) return _Color3.new(r/255, g/255, b/255) end }

TextLabel.TextColor3 = Color3.new(25, 50, 75)

Answer this question