Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

2 comments

0

happened to me also..

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.

1 answer

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.