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

What is wrong with this Rainbow Strobe light script? [closed]

Asked by 11 years ago

Could someone tell me why this script won't work? I have it under the PointLight so I can use "Parent" and the point light is 60 brightness and 60 range but it still won't work. Here is the script. It is supposed to be a strobe light that changes colors

01Script.Parent.Color = LightColor
02while true do
03    script.Parent.Enabled = true
04    wait(.01)
05    script.Parent.Enabled = false
06    Script.Parent.Color = Color.new(1004)--Really Red
07    wait(.01)
08    script.Parent.Enabled = true
09    wait(.01)
10    script.Parent.Enabled = false
11    Script.Parent.Color = Color.new("Deep Orange")
12     wait(.01)
13    script.Parent.Enabled = true
14    wait(.01)
15    script.Parent.Enabled = false
View all 29 lines...

EDIT: This is not for a Night Club, just so you know...

Locked by sgsharp and BlueTaslem

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

2 answers

Log in to vote
2
Answered by
sgsharp 265 Moderation Voter
11 years ago

First of all, PointLights' colors are Color3 values. Second of all, there are a few errors in your script. Like grammar, punctuation, and capitalization... But I've created a small, simple script for you that has almost all of the colors of the rainbow, and it changes every 0.5 seconds.

Here it is:

01local Light = script.Parent
02 
03while true do
04Light.Color = Color3.new(255/255, 0/255, 0/255) -- Red
05wait(0.5)
06Light.Color = Color3.new(255/255, 85/255, 0/255) -- Orange
07wait(0.5)
08Light.Color = Color3.new(255/255, 255/255, 0/255) -- Yellow
09wait(0.5)
10Light.Color = Color3.new(85/255, 255/255, 0/255) -- Green
11wait(0.5)
12Light.Color = Color3.new(0/255, 0/255, 255/255) -- Blue
13wait(0.5)
14Light.Color = Color3.new(170/255, 0/255, 255/255) -- Violet
15wait(0.5)
16end

Hope this helped!

0
Thanks so much! Thanks for being honest with me! Antharaziia 75 — 11y
0
You're welcome. I apologize if it came off rude. But I was just trying to help! sgsharp 265 — 11y
Ad
Log in to vote
-3
Answered by 11 years ago

PointLight objects use Color3, but you are using BrickColor codes. Here is what I suggest. First of all, make a part and but this script in the part. use BrickColor.new instead of of Color.new, and put the light in the code. Here is what the code should look like.

01Time = 0.1 --You can change this to whatever delay you need.
02Color = script.Parent.BrickColor
03LightColor = Script.Parent.PointLight.Color
04while true do
05    wait(Time)
06    Color = BrickColor.new(1004)
07    LightColor = Color.Color --BrickColor has a Property called Color that will convert a BrickColor --- color to a Color3 color
08    wait(Time)
09    Color = BrickColor.new(1017)
10    LightColor = Color.Color   
11    wait(Time)
12    Color = BrickColor.new(1009)
13    LightColor = Color.Color
14    wait(Time)
15    Color = BrickColor.new(1020)
View all 23 lines...

Now this might be all you need, but there is a much simpler way to do this. This way is just as useful, but a LOT smaller.

01Colors = {1004, 1017, 1009, 1010, 1015}
02--Put all the color codes you want in here.
03Time = 0.1
04--This is your delay.
05Color = script.Parent.BrickColor
06LightColor = script.Parent.PointLight.Color
07for i, #Colors do
08    wait(Time)
09    Color = BrickColor.new(Colors[i])
10    --Change this to Color = BrickColor.new(Colors[math.random(1, #Colors)]) for random colors.
11    LightColor = Color.Color
12end

The nice thing about this code is that you can add more colors later and it will still work. By the way, you can go here for a list of color codes. Hope this helps!