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

Help with light flicker?

Asked by
FiredDusk 1466 Moderation Voter
8 years ago

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

1
Try 1.3,6 and then if that doesn't work, use math.random(13,60)/10 theCJarmy7 1293 — 8y
0
thanks a lot! FiredDusk 1466 — 8y

1 answer

Log in to vote
2
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
8 years ago

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

Answer this question