for i = 1,1000 do
local idforram = math.random(1,500)
print(idforram)
end
It always prints 1 or 2, i ran it like 1000 times, and it prints only 1 and 2
for i = 1,1000 do
local idforram = math.random(1,500)
print(idforram)
end
It always prints 1 or 2, i ran it like 1000 times, and it prints only 1 and 2
ahem it seems like your blind or something but
for i = 1,1000 do
local idforram = math.random(1,500)
print(id) -- idforam but using id?
end
solution:
for i = 1,1000 do
local idforram = math.random(1,500)
print(idforram)
end
Its idforram
right
yes it is… obviously… I think you would be better off as a modeler. but oh well WHO AM I TO JUDGE?
What are you speaking hm
I am asking why is math.random(1,1000) always return 1 or 2
I’m running the exact same code in the terminal, and it seems to print random numbers:
10:23:34.480 467 - Edit
10:23:34.480 11 - Edit
10:23:34.480 159 - Edit
10:23:34.481 21 - Edit
10:23:34.481 114 - Edit
10:23:34.481 491 - Edit
10:23:34.481 328 - Edit
10:23:34.482 121 - Edit
10:23:34.482 89 - Edit
10:23:34.482 285 - Edit
10:23:34.482 469 - Edit
10:23:34.483 156 - Edit
10:23:34.483 207 - Edit
10:23:34.483 26 - Edit
10:23:34.483 317 - Edit
10:23:34.484 127 - Edit
10:23:34.484 379 - Edit
10:23:34.484 122 - Edit
10:23:34.484 99 - Edit
10:23:34.485 128 - Edit
10:23:34.485 347 - Edit
10:23:34.485 25 - Edit
10:23:34.485 369 - Edit
10:23:34.486 56 - Edit
10:23:34.486 475 - Edit
10:23:34.486 110 - Edit
10:23:34.486 78 - Edit
10:23:34.487 393 - Edit
10:23:34.487 166 - Edit
10:23:34.487 163 - Edit
10:23:34.487 407 - Edit
10:23:34.488 63 - Edit
10:23:34.488 328 - Edit
10:23:34.488 223 - Edit
10:23:34.488 301 - Edit
10:23:34.489 235 - Edit
10:23:34.489 255 - Edit
10:23:34.489 148 - Edit
10:23:34.489 302 - Edit
10:23:34.490 256 - Edit
10:23:34.490 76 - Edit
10:23:34.490 120 - Edit
10:23:34.490 262 - Edit
10:23:34.491 ▶ 29 (x2) - Edit
10:23:34.491 123 - Edit
10:23:34.491 350 - Edit
10:23:34.492 313 - Edit
10:23:34.492 119 - Edit
10:23:34.492 386 - Edit
10:23:34.492 417 - Edit
10:23:34.493 284 - Edit
10:23:34.493 493 - Edit
10:23:34.493 255 - Edit
10:23:34.493 250 - Edit
10:23:34.494 472 - Edit
10:23:34.494 200 - Edit
10:23:34.494 203 - Edit
10:23:34.494 35 - Edit
10:23:34.495 382 - Edit
10:23:34.495 332 - Edit
You might have to change the randomseed or reboot your system
because you arent printing the correct variable man you typed in the print statement id but the math.random(1,1000) is in the variable called idforram replace the print statement having id with idforram
nope bloxxy as he updated the code a while ago at first is was
for i = 1,1000 do
local idforram = math.random(1,500)
print(id) -- idforam but using id?
end
probably because id is a variable in your script which you didnt show us.
Hm I typed that manually but in my code, it is idforram
I immediately corrected it when I saw I typed wrong in the post, and now its still printing(1 or 2)
Oh, actually I don’t know what is randomseed can u explain please
no no, its only that, 4 line code, nothing other than that
ah it makes sense now honestly though it worked fine for me. try changing the script like putting it in a new script or try running the code in the command bar.
it still gives me 1 or 2
Using math.randomseed you can change the seed for the random number generator (RNG). You can try to set it to os.time() before the for loop.
You can also use the newer Random object using this code:
local RNG = Random.new(os.time()) -- the only argument given is the seed
for i = 1,1000 do
local idforram = RNG:NextInteger(1, 500)
print(idforram)
end
read more about the random object here: Random | Roblox Creator Documentation
It still prints 1, now its not printing 2, only 1
1 (x1000)
It is something like this in output
Are you running it in the studio terminal? Did you change anything in the script, which may change the idforram value?
I rebooted my laptop, and run it in game, and in studio, they both print same number
In game I check dev console and it prints 1 only
this weird bug started to come after this random thing appeared
can you explain what is a seed to a random.new() function? is it like the maximum number for the random number generator?
I’m not sure what’s the problem, it seems to work fine for me in all cases
That’s for building, it being added should not cause any effects for random number generators
In computer science, a seed is a starting point used by a random number generator (RNG) to generate a sequence of repetable, random numbers. Once the seed is set, the RNG produces a sequence of numbers that appear to be random, but are actually determined by the algorithm and the seed value.