Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to get a random number and then after a certain time it changes?

I think this is some of the basics, the math.random, well I wanted to ask how to make it so it changes like after 10 seconds to another number and like that in a loop?

The code i dont even know if i need to put it but here:

local randomRole = math.random(1, 3)

1 answer

✓ Accepted answer

Hey! You got the random number correct, and to answer this question you can just make a simply for loop, take time to read this as I will be going through how to do this.

for i = 1, 100 do -- you can obviously change this number to like 1, 500 or like 5, 6 0, or 50, 100 etc, it's not just needed at 1, 100. (this for loop is not needed
print(math.random(i))
wait(time) -- you can put anything you want here, but it has to be a numeral value, and or localized with a numeral value. aka local time = 1
end

4 comments

0

Hope this helped!

0

why don't you just use a while wait loop??

0

You can use that yes, but a for loop is kinda nice in this case!

0

It might not be, because it only runs a set number of times. SO if I were to stay in the game a hecka long time, the thing may no longer run. Please use while wait instead of for loops for these kind of problems.

This discussion is preserved as it was. New answers, comments, and votes are closed.