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

How do I make Lightning change colors?

Asked by 6 years ago

I have this script that makes brick change colors, but I wonder how can I make so the SpotLight inside the brick can change colors instead of brick? Here's my script:

while true do 
script.Parent.Color = Color3.new (math.random (), math.random (), math.random () )
wait(1.5)
end 
0
You have everything you need right there, if I'm not mistaken. You just need to find the spotlight in the heirarchy (script.Parent takes you to what the script is stored in; where do you go from there?) DropshipPilot 148 — 6y
0
Also, I recommend checking out the wiki on what properties spotlights have, so that you know what the name of their color property is, among other things. DropshipPilot 148 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

To be honest, your code was correct pretty much, but instead of using Color3.new() use Color3.fromRGB() instead, as it actually uses RGB values ranging from (0, 255) Also inside of math.random() you need 2 Integer arguments like this math.random(1, 10)

1 will be the first argument and 10 will be the second argument.

Below is the fix:

local light = script.Parent

while wait(1.5) do
    light.Color = Color3.fromRGB(math.random(0, 255), math.random(0, 255), math.random(0, 255))
end

If this solves your problem make sure to mark my reply as 'Answered'

Ad

Answer this question