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
n = math.random(1, 24)
print("number is" ..n)

while true do
    wait(0.01)
    if game.Lighting.ClockTime == n then
        game.ServerScriptService.Rain:Clone().Parent = game.Players.LocalPlayer.Backpack
        n = math.random(1,24)
        print("number is " ..n)
        break
    end
end

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