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

Random isnt very random?

Asked by
Wayyllon 170
4 years ago

ok. so;

01L = script.Parent.PointLight
02 
03function RNG()
04 
05    local N = math.random(.1,1.2)
06    L.Brightness = N
07end
08 
09while true do
10    wait(math.random(.7,1.4))
11    RNG()
12end

The wait random timer works fine, however, when the brightness gets changed by the "RNG" function it only goes from one brightness, then to zero, and doesn't even stay within the random parameters. (It flips back and forth from zero to one brightness each time the while true loop runs)

0
Konnichiwaa! V ;3 DiamondComplex 285 — 4y
0
thats..... not very helpful.......... Wayyllon 170 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

math.random doesn't go into decimals, you would have to divide the random number if you wanted that

01L = script.Parent.PointLight
02 
03function RNG()
04     local N = math.random(1, 12) / 10
05     L.Brightness = N
06end
07 
08while true do
09     wait(math.random(7, 14) / 10)
10     RNG()
11end
0
Or just use Random.new():NextNumber()'s min/max overflow. Ziffixture 6913 — 4y
Ad

Answer this question