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

super noob question. how do i make a wait() do random between?

Asked by
nicros 165
9 years ago

super noob question but im new so shaddup :C.

how do i make a wait() do random between 2 numbers?

for example click something and it waits between 1 to 5 seconds before doing the next block of code?

0
Super noob question? More like super good question! It's not even a stupid or an noob question! For seriously! I dont know how to do that to! asgppl 5 — 6y

3 answers

Log in to vote
1
Answered by 9 years ago

While this question might be nooby(no offense), this thingy that we'll learn will be super useful in your scripting career

We'll be using the math.random property of math

If we read what the wiki says(you can go to the wiki by pressing math.random in the second sentence), it says:

here is a random number generator in Roblox that seems to generate random numbers. But do a test, and insert this script into your place:

for _ = 1, 10 do
    print(math.random(100))
    wait(1)
end

alright! now we know that math.random is quite a helpful thingy!

but, there's a catch, math.random gives similar(if not the same) numbers everytime!

so, how could we get around this?

The math.randomseed property of math

we'll use that to randomize our random number even more!

math.randomseed(tick())

math.randomseed takes an argument 'seed', which is easy to give, just use tick().

So? now what?

by taking what we learned today, we can combine them together.

math.randomseed(tick()) --To make random randomer

wait(math.random(1,5))

Now we have a random timer!

*Note to use math.randomseed BEFORE you use math.random

0
ty so much nicros 165 — 9y
Ad
Log in to vote
2
Answered by 9 years ago

Firstly, if you want to have a random number wait time, we will use math.random.

math.random(num1,num2)

In this, num1 is the minimum the random can be, and num2 is the maximum. So for example, lets have 1 as the minimum and 10 as the maximum. And print it.

print(math.random(1,10))

This will print a random number between 1 and 10. But it we want it to wait that amount of time, we will have to put the math.random() inside the wait.

wait(math.random(minimum,maximum))

And voila! A random wait time with a minimum and a maximum.

0
thanks so much nicros 165 — 9y
Log in to vote
-2
Answered by
traigla 75
9 years ago
wait(math.random(1,5))

Try that.

1
you got to explain your answer homie ;p HungryJaffer 1246 — 9y

Answer this question