It runs the script with no error but doesn't actually do anything. What should I do?
local c = game.Workspace.Part.PointLight.Color
while true do
c = Color3.new(255,0,0)
wait(0.15)
c = Color3.new(255,0,85)
wait(0.15)
c = Color3.new(255,0,170)
wait(0.15)
c = Color3.new(255,0,255)
wait(0.15)
c = Color3.new(170,0,255)
wait(0.15)
end
Its obivous really,Your changing the color each time,But your not dong anything with it. Try :
lc = game.Workspace.Part.PointLight while true do wait() lc.Color = Color3.new(255,0,0) wait(0.15) lc.Color = Color3.new(255,0,85) wait(0.15) lc.Color = Color3.new(255,0,170) wait(0.15) lc.Color = Color3.new(255,0,255) wait(0.15) lc.Color = Color3.new(170,0,255) wait(0.15) end
Hope it helped :D
NEITHER answer is correct. The actual answer is that when you're creating a Color3
, you don't use integers as the arguments. You use decimal values in the range of 0 - 1. I've rewritten your script to work. As you'll notice, I'm dividing each value by 255, the maximum value of a color, because doing this gives me a decimal value back, which is how to properly set a Color3
. You'll also notice that for the 0's, I'm not dividing them at all. That is because it is more efficient and still just as readable, because to divide zero by 255 still gives us 0, but just writing 0 is faster for Lua
to understand.
lc = game.Workspace.Part.PointLight while true do wait() lc.Color = Color3.new(255 / 255, 0, 0) wait(0.15) lc.Color = Color3.new(255 / 255, 0, 85 / 255) wait(0.15) lc.Color = Color3.new(255 / 255, 0, 170 / 255) wait(0.15) lc.Color = Color3.new(255 / 255, 0, 255 / 255) wait(0.15) lc.Color = Color3.new(170 / 255, 0, 255 / 255) wait(0.15) end