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

How to change light color?

Asked by 9 years ago

I need this script to change the light's color every .1 second. Why won't it work?

while true do
       script.Parent.Spotlight.Color = Color3.new(math.random(), math.random(), math.random())
       wait(0.1)
end

Btw this is for a nightclub map in one of my games :D

2 answers

Log in to vote
1
Answered by
Merely 2122 Moderation Voter Community Moderator
9 years ago

I tested it in Studio and it does work. Did you typo "Spotlight" instead of "SpotLight"? Or maybe your script's Parent doesn't contain the Spotlight object.

0
Your right. It was a typo. Thanks! Antharaziia 75 — 9y
0
For the future, in Studio you can look at the Output window and it will show you errors like this. In online mode you can press F9 to open the Developer Console, which also shows the output. Merely 2122 — 9y
0
Wait a sec... I just realized... MERELY NOTICED ME AND ANSWERED MY QUESTION!! OMFG, I AM FREAKING OUT RIGHT NOW! Antharaziia 75 — 9y
Ad
Log in to vote
0
Answered by
l0cky2013 135
9 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.
while true do
       script.Parent.SpotLight.Color = Color3.new(math.random(1,255)/255, math.random(1,255)/255, math.random(1,255)/255); 
       wait(0.1)
end

This should do it. Be warned that I renamed Spotlight to SpotLight.

Answer this question