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

Any way to give a time for math.random choose a number again?

Asked by 3 years ago

Is there any way for give a time for math.random choose same number again? if print 1, then 1 can be choosen again in 10 seconds for example.

local numbers = {1,2,3,4,5,6,7,8,9,10}
local randomTrack = numbers[math.random(1,#numbers)]    
if randomTrack ==1 then
print("1")
end
if randomTrack ==2 then
print("2")
end
if randomTrack ==3 then
print("3")
end
end

1 answer

Log in to vote
0
Answered by 3 years ago

Here is a way. Its a bit more simple. Hope you dont mind!

while wait(2) do
    local randomTrack = math.random(1,10)
    print(randomTrack)
end
Ad

Answer this question