Ad
Log in to vote
0

Math.Random() isnt working for me?

Asked by 10 months ago
Edited 10 months 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 roblor12 166 — 10mo
0
use "math.randomseed(tick())" at the start of your scriot and only the start abnotaddable 862 — 10mo
0
I notice you print `n` but you aren't printing `ClockTime`. Try printing `ClockTime` and I think you will see the problem. Validark 1531 — 10mo
0
Also, make `n` a local variable by making the first line have `local n` instead of `n` Validark 1531 — 10mo

1 answer

Log in to vote
0
Answered by 10 months 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