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)
How would I be able to get the full RGB value like 255, 0, 0
by printing it?
Frames and text label:
My code:
script.Parent.PurchaseColor.TextButton.MouseButton1Click:Connect(function()
print(script.Parent.PreviewColor.PreviewColor.TextColor3)
end)
prepsure
(paige)
February 18, 2021, 12:01am
#2
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.
1 Like
Try a different color instead of black. I tried a teal color but it printed this:
Trayeus
(Trayeus)
February 18, 2021, 12:13am
#4
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.
BIackShibe
(BIackShibe)
February 18, 2021, 12:17am
#6
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?
Trayeus
(Trayeus)
February 18, 2021, 12:25am
#8
Did a simple test of this:
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:
2 Likes
BIackShibe
(BIackShibe)
February 18, 2021, 12:26am
#9
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
Trayeus
(Trayeus)
February 18, 2021, 12:27am
#11
Of course, glad to help! Make sure to mark the solution!
If you need anymore help feel free to comment back here.
1 Like