I want to add a 15 percent red tint on part but it wont let me
line of code it errors on
workspace.Bottom.Color = Color3.fromRGB(workspace.Bottom.Color + 15 ,0,0)
the error:
attempt to perform arithmetic (add) on Color3 and number
I want to add a 15 percent red tint on part but it wont let me
line of code it errors on
workspace.Bottom.Color = Color3.fromRGB(workspace.Bottom.Color + 15 ,0,0)
the error:
attempt to perform arithmetic (add) on Color3 and number
Index the red value of the color:
workspace.Bottom.Color.R + 15
I tried that at first but it errored with (mul) instead of (add)
Sorry, forgot to say that you need to multiply the value by 255 and round it.
math.round((workspace.Bottom.Color.R * 255) + 15)
i replaced it but nothing happens nothing n output either
Hmm…
Did you place that line alone?
I meant to replace that piece of code only.
This si the whole section of the script
Look, this line should be like the following:
workspace.Bottom.Color = Color3.fromRGB(math.round((workspace.Bottom.Color.R * 255) + 15), 0, 0)
Are you trying to add 15 to all the values of the color?
No i want to make it 15 percent more red
So, you just need to get the other values: green and blue then multiply them by 255.
Here is what it should be:
local Red, Green, Blue = workspace.Bottom.Color.R, workspace.Bottom.Color.G, workspace.Bottom.Color.B
workspace.Bottom.Color = Color3.fromRGB(math.clamp(math.round(workspace.Bottom.Color.R * 255) + 15, 0, 255), math.round(Green * 255), math.round(Blue * 255))
math.clamp
is used to make sure that the red value doesn’t go above 255.
It worked!! Thank you for helping, i couldn’t understand any other posts similar to this one
Hey,
I recommend you use this code instead:
local Red, Green, Blue = workspace.Bottom.Color.R, workspace.Bottom.Color.G, workspace.Bottom.Color.B
workspace.Bottom.Color = Color3.new(math.clamp(Red + (15 / 255), 0, 1), Green, Blue)
That won’t require to convert the color values to RGB and more readable.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.