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.
If you're looking for more realistic results, speed up the flicker and refrain from making math.random
a variable
as it will stay at that number and wont change.
I've re-written the script for you.
local Light = script.Parent.SpotLight while true do Light.Enabled = not Light.Enabled wait(math.random()) Light.Enabled = not Light.Enabled wait(math.random()) end