Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What is wrong with this Rainbow Strobe light script?

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

Script.Parent.Color = LightColor
while true do
    script.Parent.Enabled = true
    wait(.01)
    script.Parent.Enabled = false
	Script.Parent.Color = Color.new(1004)--Really Red
	wait(.01)
    script.Parent.Enabled = true
    wait(.01)
    script.Parent.Enabled = false
	Script.Parent.Color = Color.new("Deep Orange")
	 wait(.01)
	script.Parent.Enabled = true
    wait(.01)
    script.Parent.Enabled = false
	LightColor = Color.new("New Yeller")
	script.Parent.Enabled = true
    wait(.01)
    script.Parent.Enabled = false
	LightColor = Color.new(1020)--Lime Green
	script.Parent.Enabled = true
    wait(.01)
    script.Parent.Enabled = false
	LightColor = Color.new(1010)--New Blue I think
	script.Parent.Enabled = true
    wait(.01)
    script.Parent.Enabled = false
	LightColor = Color.new(1015)--Magenta
end

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

2 answers

✓ Accepted answer

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:

local Light = script.Parent

while true do
Light.Color = Color3.new(255/255, 0/255, 0/255) -- Red
wait(0.5)
Light.Color = Color3.new(255/255, 85/255, 0/255) -- Orange
wait(0.5)
Light.Color = Color3.new(255/255, 255/255, 0/255) -- Yellow
wait(0.5)
Light.Color = Color3.new(85/255, 255/255, 0/255) -- Green
wait(0.5)
Light.Color = Color3.new(0/255, 0/255, 255/255) -- Blue
wait(0.5)
Light.Color = Color3.new(170/255, 0/255, 255/255) -- Violet
wait(0.5)
end

Hope this helped!

2 comments

0

Thanks so much! Thanks for being honest with me!

0

You're welcome. I apologize if it came off rude. But I was just trying to help!

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.

Time = 0.1 --You can change this to whatever delay you need.
Color = script.Parent.BrickColor
LightColor = Script.Parent.PointLight.Color
while true do
    wait(Time)
    Color = BrickColor.new(1004)
    LightColor = Color.Color --BrickColor has a Property called Color that will convert a BrickColor --- color to a Color3 color
    wait(Time)
    Color = BrickColor.new(1017)
    LightColor = Color.Color    
    wait(Time)
    Color = BrickColor.new(1009)
    LightColor = Color.Color
    wait(Time)
    Color = BrickColor.new(1020)
    LightColor = Color.Color
    wait(Time)
    Color = BrickColor.new(1010)--There is no New Blue, but this is Really Blue.
    LightColor = Color.Color
    wait(Time)
    Color = BrickColor.new(1015)
    LightColor = Color.Color
end

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.

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

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.