I have this script where it makes a light look like it is flickering and I am getting this error: Workspace.Lights.Model.Model2.Light.Flicker:11: bad argument #2 to 'random' (interval is empty)
SpotLight = script.Parent:WaitForChild("Light").SpotLight Light1 = script.Parent.Part1 Light2 = script.Parent.Part2 Light3 = script.Parent.Part3 Light4 = script.Parent.Part4 Light5 = script.Parent.Part5 Light6 = script.Parent.Part6 while true do wait(math.random(.6,.1)) SpotLight.Enabled = false Light1.Material = "SmoothPlastic" Light2.Material = "SmoothPlastic" Light3.Material = "SmoothPlastic" Light4.Material = "SmoothPlastic" Light5.Material = "SmoothPlastic" Light6.Material = "SmoothPlastic" wait(math.random(.6,1.3)) SpotLight.Enabled = true Light1.Material = "Neon" Light2.Material = "Neon" Light3.Material = "Neon" Light4.Material = "Neon" Light5.Material = "Neon" Light6.Material = "Neon" end
The two argument form of math.random
is only supposed to be used with whole numbers.
If you want a random number between low
and high
, you can use the no argument math.random()
which returns between 0 and 1.
You can multiply and add to get this into the range you want:
wait( 0.6 + (1.3-0.6) * math.random() )