Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

RGB values with Color3 won't set to a proper value on lights?

Asked by 6 years ago

I'm trying to make a Point Light fade colours using this script:


local Red = 255 local Green = 0 local Blue = 0 local ColorValueSet = script.Parent.Parent.Parent.Part spawn(function(SetColour) while wait(0.1) do script.Parent.Parent.PointLight.Color = Color3.new(Red,Green,Blue) print(Red,Green,Blue) end end) while wait(0.1) do for i = 0,255 do wait(0.1) Green = i end wait(0.1) for i = 255,0 do wait(0.1) Red = i end for i = 0,255 do Blue = i wait(0.1) end for i = 255,0 do wait(0.1) Green = i end for i = 0,255 do wait(0.1) Red = i end for i = 255,0 do Blue = i wait(0.1) end end

The code above appears to be working properly, but for some reason, the RGB values on the actual Point Light appear to be bugged: https://gyazo.com/1c8fd40df4581d83f6f0e558687976e8

0
happened to me also.. greatneil80 2647 — 6y
0
Color3.new requires numbers between 0 and 1, due to how it was designed. To get the proper color, you need to either 1. Continue to use Color3.new() and divide the RGB colors by 255, or 2. Move to using Color3.fromRGB() and continue using integer values. M39a9am3R 3210 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago

Hello xBlueSparks,

I used to have this as well. Luckily I have a fix. Color3 uses any value between 0 and 1. A workaround for this goes like this:

local Red = 255
local Green = 0
local Blue = 0

local ColorValueSet = script.Parent.Parent.Parent.Part


spawn(function(SetColour)
while wait(0.1) do
script.Parent.Parent.PointLight.Color = Color3.new(Red/255,Green,Blue) -- Divide your values by 255, seeing as the max in RGB is 255. This doesn't have to be done when your value is 0
print(Red,Green,Blue)
end
end)

I hope this helps you out! If you still have questions, feel free to ask!

Regards,

DefaultAxis

Ad

Answer this question