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

What's wrong with my flashing light script?

Asked by 7 years ago

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

Log in to vote
0
Answered by 7 years ago

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
Ad

Answer this question