Hello,
I would like to know how I would go about fading a point light's color from one color to another? I know that it's a Color3 but I am not exactly sure how I would go about doing it. Would I use a for loop?
Thanks,
Anthony
Hello,
I would like to know how I would go about fading a point light's color from one color to another? I know that it's a Color3 but I am not exactly sure how I would go about doing it. Would I use a for loop?
Thanks,
Anthony
Here's an example of that being done:
local Light = script.Parent
local FadeCount = 100
local FadeTime = 5
local function ChangeColor(Color, Light)
local oc = Light.Color
local rd = Color.r - oc.r
local gd = Color.g - oc.g
local bd = Color.b - oc.b
print(Color.b,oc.b)
for i=0, 1+(1/FadeCount), 1/FadeCount do
wait(FadeTime/FadeCount)
local NewColor = {r=0,g=0,b=0}
NewColor.r = oc.r + ((rd)*i)
NewColor.g = oc.g + ((gd)*i)
NewColor.b = oc.b + ((bd)*i)
Light.Color = Color3.new(NewColor.r, NewColor.g, NewColor.b)
end
Light.Color = Color
end
wait(5)
ChangeColor(Color3.fromRGB(0,0,255), Light)
wait(2)
ChangeColor(Color3.fromRGB(255,255,0), Light)
Try using Color:FromRGB()! http://wiki.roblox.com/index.php?title=API:Color3
This discussion is preserved as it was. New answers, comments, and votes are closed.