So I'm working with a point light, and I'm trying to get a glowing effect that gradually changes from one color to another.
light = script.Parent; r =0-- math.random (0,255) g = 0--math.random (0,255) b = 255--math.random (0,255) colors = {r,g,b} function UpdateColor () light.Color = Color3.new (r/255,g/255,b/255) wait (.1) end while wait () do print 'stage 1' for i = 0,50-r do if r < 255 then r = r + 5; UpdateColor () -- fades to purple, this is where the color is 255,0,255 else r = 0; UpdateColor () end end print 'stage 2' for i = 0,50-b do -- 50 is one less than 255/5. if b > 0 then b = b - 5; -- this is why I divide it by 5 UpdateColor () -- fades to red, this doesn't work! Right now the color is still 255,0,255 else b = 255; UpdateColor () end end
Any and all help will be appreciated.
You can, the problem is that the statement is not being executed because of
for i = 0,50-b do
Since b = 255, 50 - 255 is -205, so for 0,-205 is not going to execute because the default step is 1
It is going to -205 because the variable b = 255...........