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

Is it possible to make a Random Wait() Timer?

I want to understand the consept of > Math.Random

However i want to do an example of this But in a Advance way

while true do wait(0.1) print('Is_On') wait(0.1) print('Is_Off') end

I want it to be a random wait timer instead of an event occurring every wait(0.1) Time.

This timer that i am trying to conduct should Instead of Wait Time, Should be ticket to random seconds to functions these operations.

for x = 1,2 do wait(math.random) print('Is_On') wait(math.random) print('Is_Off') end

3 answers

✓ Accepted answer
for x = 1,2 do 
	wait(math.random(1,5)) 
	print('Is_On')
	wait(math.random(1,5))
	print('Is_Off') 
end

Since this is the code you put, what I did was edit the waits so it has both parameters since if you left it like that it would probably give an error.

1 comment

0

Ah, i see how you did it now! Thanks!

math.Random()

is a function that runs by inputed arguments inside parenthesis. Therefore, you will have to state the range of numbers that you want to generate, for example,

math.Random(1,10)

will return any numbers between 1-10.

If you want some more variation in math.random, trying to simply input decimal values into math.random won't work. That's because math.random only supports integer values, which means that decimal values can't be inputted. However, it is possible to divide the value math.random returns.

math.random(1,100)/100 --Returns a value between 0.01 and 1.00

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