What do you want to achieve? Keep it simple and clear!
basically what I want to do is make a Part and PointLight more brighter and saturated everytime I right-click
What is the issue? Include screenshots / videos if possible!
when I try it gives me [path to script]:7: attempt to perform arithmetic (add) on Color3
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I did try to look for solutions on the DevHub, however I couldn’t find my problem
here is the script if you need it:
game:GetService("UserInputService").InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton2 then
local handleh, handles, handlev
local handleh, handles, handlev = Color3.toHSV(script.Parent.Handle.Color)
if handlev >= 0.6235294342041016 then return end
if script.Parent.Handle.PointLight.Brightness >= 1 then return end
script.Parent.Handle.Color += Color3.fromRGB(0, 12.23, 8.07)
script.Parent.Handle.PointLight.Brightness += 0.075
script.Parent.Handle.Sound:Play()
end
end)
RGB is red,green,blue HSV is hue,saturation,and value, by using HSV you can set the color and then control the lighting easier instead of manually adjusting it with RGB
You are receiving this error because you cannot directly add colors by doing .Color += num. Instead, you can break down the color into its three components, R, G, and B, and increment those values independently.
The .Color property in specific gives you a number from 0-1 representing how much of each value is used. In practice, we want values from 0-255, because we are more familiar with that as a representation of RGB.
An implementation could look like this:
local part = workspace.Baseplate
print(part.Color)
-- Prints 0.356863, 0.356863, 0.356863
print(part.Color.R * 255, part.Color.B * 255, part.Color.G * 255)
-- Prints 91, 91, 91 (more or less)
So to increment a parts color:
local increment = 10
-- Assuming we're using the same part as before:
local r = math.floor(part.Color.R * 255) + increment
local g = math.floor(part.Color.G * 255) + increment
local b = math.floor(part.Color.B * 255) + increment
part.Color = Color3.fromRGB(r, g, b)