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

What's wrong with my flashing light script?

I'm trying to make a light flash repeatedly but it isn't working. This is the script I have inside the light.

Light = script.Parent


function FlashLights()
	repeat
		wait(math.Random(.2,2))
		Light.Material = "Neon"
		wait(.2)
		Light.Material = "SmoothPlastic"
	until false
end

It's probably an obvious mistake but there's no error messages and I'm confused about what I did wrong.

1 answer

Hello. This is actually an easy fix. This is a function and it has never been called. In order for your script to work you need to call it first, and you want the light to repeatedly flash constantly right? So this is what your code SHOULD be:

light = script.Parent

function flash()
      Light.Material = "Neon"
      wait(.2)
      Light.Material = "SmoothPlastic"
end

while wait() do
      wait(math.random(.2,2))
      flash()
end

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