how to properly add the saturation level on a certain color3?
plr.TeamColor.Color+Color3.new(0,.3,0) --errors
525: attempt to perform arithmetic (add) on Color3
08:04:51.246 Stack Begin
how to properly add the saturation level on a certain color3?
plr.TeamColor.Color+Color3.new(0,.3,0) --errors
525: attempt to perform arithmetic (add) on Color3
08:04:51.246 Stack Begin
local Color = plr.TeamColor.Color
plr.TeamColor.Color = Color3.new(Color.R, Color.G + 0.3, Color.B)
Not this. This isn’t saturation, this is just adding to green.
Color3 has a method called ToHSV - Hue, Saturation and Value. You can break a Color3 into these three values, add to the saturation value and then use fromHSV to reconstruct back a Color3 with a different saturation, not just an increment in one colour.
local myColor = Color3.new(0.5, 0.5, 0.5)
local hue, saturation, value = myColor:ToHSV()
saturation = math.clamp(saturation + 0.5, 0, 1)
local myNewColor = Color3.fromHSV(hue, saturation, value)
print(myColor) -- 0.5, 0.5, 0.5
print(myNewColor) -- 0.5, 0.25, 0.25
I’m having trouble on understanding math.clamp.
Heres a post explaning about it. math.clamp(x,y,z) where x could be any value, y is the minimum and z is the maximum. say y = 1 and z = 5. if the x value is < y then the result will be y, same goes with z.