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

Help with light flicker?

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

2 comments

1

Try 1.3,6 and then if that doesn't work, use math.random(13,60)/10

0

thanks a lot!

1 answer

✓ Accepted answer

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() )

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