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

Math.Random() isnt working for me?

Asked by
Galicate 106
7 years ago
Edited 7 years ago
01n = math.random(1, 24)
02print("number is" ..n)
03 
04while true do
05    wait(0.01)
06    if game.Lighting.ClockTime == n then
07        game.ServerScriptService.Rain:Clone().Parent = game.Players.LocalPlayer.Backpack
08        n = math.random(1,24)
09        print("number is " ..n)
10        break
11    end
12end
0
It works, just check your 'ClockTime' line, does ClockTime returns whole number? . 1-24 ? I've never used ClockTime before tho User#17685 0 — 7y
0
use "math.randomseed(tick())" at the start of your scriot and only the start abnotaddable 920 — 7y
0
I notice you print `n` but you aren't printing `ClockTime`. Try printing `ClockTime` and I think you will see the problem. Validark 1580 — 7y
0
Also, make `n` a local variable by making the first line have `local n` instead of `n` Validark 1580 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

The problem is that for you is that math.random is based on the number you got before. Thats why IT always Will return the same Value IF its not running more then once.

Ad

Answer this question