Hi, I have problem, that I have qui image labels, that are only white and alpha and i need to add them in-game in many colors, so do i need to export it in every color variant, or can i recolor it by script?
Yes, with the ImageColor3
property
script.Parent.ImageColor3 = Color3.new(1,0,0)
You can accomplish this by changing the ImageColor3
property.
https://developer.roblox.com/en-us/api-reference/property/ImageLabel/ImageColor3
It is recommended to use Color3.fromRGB(value, value, value)
instead of Color3.new(value, value, value)
(because you can only put value either 0 to 1 and I bet you’re more used to working with the RGB values.)
If you’re using fromRGB, then you can just copy paste the value the same way you’d set color for any parts
For example:
ImageColor3 = Color3.fromRGB(255, 255, 255)
– white
ImageColor3 = Color3.fromRGB(255, 0, 0)
– Really red
There is also a handy color selector that you can find in the properties.
" Color3 returns a Color3 with the given red, green, and blue values. The numbers can range from 0 to 1. "
I don’t know about the last part but
local my_ImageLabel = script.Parent
my_ImageLabel.BackgroundColor3 = Color3.new(12,122,12)
my_ImageLabel.ImageColor3 = Color3.new(12,32,42)
----or from RGB
my_ImageLabel.ImageColor3 = Color3.new(12/255, 122/255, 12/255)
This is wrong. It should be:
Color3.new(12/255, 122/255, 12/255)
Color3.new(12/255, 32/255, 42/255)
Constructing a Color3 with the same Color3 makes no sense. That’s not how Color3.fromRGB
works: it takes integers from 0 - 255 so you don’t have to divide it by 255 when using Color3.new
.
Color3.fromRGB(255, 127, 9)