This script is supposed to make a SpotLight turn on and off, but I haven't gotten any good results. The light just stays on indefinitely. This script is in a part called "Light1", and there is a SpotLight inside Light1.
local light = script.Parent.SpotLight
local time1 = math.random(1, 5)
local time2 = math.random(1, 5)
function flicker()
while true do
light.Enabled = true
wait(time1)
light.Enabled = false
wait(time2)
end
end
I don't know what I did wrong and the script checker thingy didn't say there were any exceptions.

2 comments
Works like a charm. Thanks!
Use
math.random()instead ofmath.random(1,10) / 10-- much briefer and won't be in intervals of tenths of a second