Printing RGB Color Value through TextLabel

I’m attempting to make a color wheel that displays the RGB Color Value through the text color on the TextLabel. While doing this, I’ve gotten random numbers printing out (image attached below)

image

How would I be able to get the full RGB value like 255, 0, 0 by printing it?

Frames and text label:
image

My code:

script.Parent.PurchaseColor.TextButton.MouseButton1Click:Connect(function()
   print(script.Parent.PreviewColor.PreviewColor.TextColor3)
end)

Are you sure you’re looking at the right message in the output? I’m printing the textcolor3 of a label in one of my games via the command line and I don’t get the same thing.
image

1 Like

Try a different color instead of black. I tried a teal color but it printed this:

image

Well, you could always try to print the individual values like so:

script.Parent.PurchaseColor.TextButton.MouseButton1Click:Connect(function()
   local textColor3 = script.Parent.PreviewColor.PreviewColor.TextColor3
   print(textColor3.R, textColor3.G, textColor3.B)
end)
1 Like

Tried that as well, outputted the same value.

RGB is stored from range 0-1, just do *255 and math.floor() to get the original RGB

3 Likes

I never really tried math.floor() before. How would the code look from there?

Did a simple test of this:

image

script.Parent.TextButton.MouseButton1Click:Connect(function()
	local textColor3 = script.Parent.TextLabel.TextColor3
	print(textColor3.R, textColor3.G, textColor3.B)
	print(math.floor(textColor3.R * 255), math.floor(textColor3.G * 255), math.floor(textColor3.B * 255))
end)

Output:
image

2 Likes

math.floor() floors the number

print(math.floor(12.345)) --> 12

you can just wrap all of the values in that

print(math.floor(color.R * 255), math.floor(color.G * 255), math.floor(color.B * 255))
2 Likes

I see the issue now what I was doing with math.floor(). Thanks for the help @Trayeus & @BIackShibe!

1 Like

Of course, glad to help! :slight_smile: Make sure to mark the solution! :smiley:
If you need anymore help feel free to comment back here.

1 Like