01 | while true do |
02 |
03 | wait(math.random( 1 , 4 )) |
04 |
05 | print ( "num1" ) |
06 |
07 | wait(math.random( 1 , 4 )) |
08 |
09 | print ( "num2" ) |
10 |
11 | wait(math.random( 1 , 4 )) |
12 |
13 | print ( "num3" ) |
14 |
15 | end |
The script would wait the randomly given time and then it would print the "num1" and it would move on to num2 then after some time num3, but how do I make it so it prints all 3 numbers at the same time with the math.random function in one script?
I'm not completely sure if I understood what you're asking correctly, but based on how I interpreted your question, I think this code would work for you:
1 | while true do |
2 | wait(math.random( 1 , 4 )) |
3 | wait(math.random( 1 , 4 )) |
4 | wait(math.random( 1 , 4 )) |
5 |
6 | print ( "num1" ) |
7 | print ( "num2" ) |
8 | print ( "num3" ) |
9 | end |
Also, if num1, num2, and num3 are variables, you'll want to change the prints to print(num1)
, print(num2)
, and print(num3)
.
Try using this:
1 | while true do |
2 | wait( 1 ) |
3 | spawn( function () |
4 | wait(math.random( 1 , 4 )) |
5 | print (“bruh”) |
6 | end ) |
7 | end |
I typed this script on my phone btw so could be wrong
Spawn calls a function on a new thread, meaning that there is no wait for the function to return, so more than 2 processes can happen at once
Accept this answer if worked