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
3 years ago

ok. so;

L = script.Parent.PointLight

function RNG()

    local N = math.random(.1,1.2)
    L.Brightness = N
end

while true do
    wait(math.random(.7,1.4))
    RNG()
end

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 — 3y
0
thats..... not very helpful.......... Wayyllon 170 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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


L = script.Parent.PointLight function RNG() local N = math.random(1, 12) / 10 L.Brightness = N end while true do wait(math.random(7, 14) / 10) RNG() end
0
Or just use Random.new():NextNumber()'s min/max overflow. Ziffixture 6913 — 3y
Ad

Answer this question