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

How to make a wait where the wait time is randomized between x and y?

Asked by 8 years ago

example wait(x-y) Something that would act like that

1 answer

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
8 years ago

math.random() will give you a random number, evenly distributed between 0 and 1.

Thus 10 * math.random() is evenly distributed between 0 and 10.

15 + 10 * math.random() is evenly distributed between 15 and 15+10=25.

In general x + (y - x) * math.random() is evenly distributed between x and y.

Ad

Answer this question