Ad
Log in to vote
0

Math.Random() isnt working for me?

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

1 answer

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



Ad