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

Math.random is broken?

Asked by
RubenKan 3615 Moderation Voter Administrator Community Moderator
10 years ago

Hey everyone, im with a question here.

I've made a motherload, and it generates a random field every time i launch a game on test-mode. However, When i play it in normal mode (Play on the site) it always generates the same terrain.

Does anyone know if this is a known bug or something that could be wrong? The math.random goes from -30000 to 6250.

0
Did you try setting a randomseed? BlackJPI 2658 — 10y

1 answer

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

Well, when I ran the code print(math.random(-30000,6250)) in studio, I got the following output:

--[[
> print(math.random(-30000,6250))
-17271
> print(math.random(-30000,6250))
-7835
> print(math.random(-30000,6250))
-3540
> print(math.random(-30000,6250))
3027
> print(math.random(-30000,6250))
-5261
> print(math.random(-30000,6250))
-16017
--]]

Since this does seem random, I believe that your problem lies not with math.random but with some other part of your code.

0
no, i mean that it always comes out the same on multi player, create a place with this (ive also done that), it will always come at the same values RubenKan 3615 — 10y
0
No, it works exactly the same in online mode. I just tested it. Perci1 4988 — 10y
Ad

Answer this question