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

How to make math.Random Constanly pick a number?

Asked by 4 years ago

I made this script to use the math.random but I cant get it to pick another number afterwards

local un = math.random(1,32)
if un == 1 then
    game.ServerScriptService.HyugaDNA.Disabled = false
    wait(40)
    game.ServerScriptService.HyugaDNA.Disabled = true
end
if un == 2 then
    game.ServerScriptService.HyugaDNA.Disabled = false
    wait(40)
    game.ServerScriptService.HyugaDNA.Disabled = true
end
if un == 3 then
    game.ServerScriptService.HyugaDNA.Disabled = false
    wait(40)
    game.ServerScriptService.HyugaDNA.Disabled = true
end
if un == 4 then
    game.ServerScriptService.HyugaDNA.Disabled = false
    wait(40)
    game.ServerScriptService.HyugaDNA.Disabled = true
end
if un == 5 then
    game.ServerScriptService.HyugaDNA.Disabled = false
    wait(40)
    game.ServerScriptService.HyugaDNA.Disabled = true
end
if un == 6 then
    game.ServerScriptService.HyugaDNA.Disabled = false
    wait(40)
    game.ServerScriptService.HyugaDNA.Disabled = true
end
if un == 7 then
    game.ServerScriptService.HyugaDNA.Disabled = false
    wait(40)
    game.ServerScriptService.HyugaDNA.Disabled = true
end
if un == 8 then
    game.ServerScriptService.HyugaDNA.Disabled = false
    wait(40)
    game.ServerScriptService.HyugaDNA.Disabled = true
end
if un == 9 then
    game.ServerScriptService.HyugaDNA.Disabled = false
    wait(40)
    game.ServerScriptService.HyugaDNA.Disabled = true
end
if un == 10 then
    game.ServerScriptService.HyugaDNA.Disabled = false
    wait(40)
    game.ServerScriptService.HyugaDNA.Disabled = true
end
if un == 11 then
    game.ServerScriptService.HozukiDNA.Disabled = false
    wait(40)
    game.ServerScriptService.HozukiDNA.Disabled = true
end
if un == 12 then
    game.ServerScriptService.HozukiDNA.Disabled = false
    wait(40)
    game.ServerScriptService.HozukiDNA.Disabled = true
end
if un == 13 then
    game.ServerScriptService.HozukiDNA.Disabled = false
    wait(40)
    game.ServerScriptService.HozukiDNA.Disabled = true
end
if un == 14 then
    game.ServerScriptService.HozukiDNA.Disabled = false
    wait(40)
    game.ServerScriptService.HozukiDNA.Disabled = true
end
if un == 15 then
    game.ServerScriptService.HozukiDNA.Disabled = false
    wait(40)
    game.ServerScriptService.HozukiDNA.Disabled = true
end
if un == 16 then
    game.ServerScriptService.HozukiDNA.Disabled = false
    wait(40)
    game.ServerScriptService.HozukiDNA.Disabled = true
end
if un == 17 then
    game.ServerScriptService.HozukiDNA.Disabled = false
    wait(40)
    game.ServerScriptService.HozukiDNA.Disabled = true
end
if un == 18 then
    game.ServerScriptService.HozukiDNA.Disabled = false
    wait(40)
    game.ServerScriptService.HozukiDNA.Disabled = true
end
if un == 19 then
    game.ServerScriptService.HozukiDNA.Disabled = false
    wait(40)
    game.ServerScriptService.HozukiDNA.Disabled = true
end
if un == 20 then
    game.ServerScriptService.HozukiDNA.Disabled = false
    wait(40)
    game.ServerScriptService.HozukiDNA.Disabled = true
end
if un == 21 then
    game.ServerScriptService.YukiDNA.Disabled = false
    wait(40)
    game.ServerScriptService.YukiDNA.Disabled = true
end
if un == 22 then
    game.ServerScriptService.YukiDNA.Disabled = false
    wait(40)
    game.ServerScriptService.YukiDNA.Disabled = true
end
if un == 23 then
    game.ServerScriptService.SenjuDNA.Disabled = false
    wait(40)
    game.ServerScriptService.SenjuDNA.Disabled = true
end
if un == 24 then
    game.ServerScriptService.SenjuDNA.Disabled = false
    wait(40)
    game.ServerScriptService.SenjuDNA.Disabled = true
end
if un == 25 then
    game.ServerScriptService.SenjuDNA.Disabled = false
    wait(40)
    game.ServerScriptService.SenjuDNA.Disabled = true
end
if un == 26 then
    game.ServerScriptService.UzumakiDNA.Disabled = false
    wait(40)
    game.ServerScriptService.UzumakiDNA.Disabled = true
end
if un == 27 then
    game.ServerScriptService.UzumakiDNA.Disabled = false
    wait(40)
    game.ServerScriptService.UzumakiDNA.Disabled = true
end
if un == 28 then
    game.ServerScriptService.UzumakiDNA.Disabled = false
    wait(40)
    game.ServerScriptService.UzumakiDNA.Disabled = true
end
if un == 29 then
    game.ServerScriptService.UzumakiDNA.Disabled = false
    wait(40)
    game.ServerScriptService.UzumakiDNA.Disabled = true
end
if un == 30 then
    game.ServerScriptService.SaiyanDNA.Disabled = false
    wait(40)
    game.ServerScriptService.SaiyanDNA.Disabled = true
end
if un == 31 then
    game.ServerScriptService.UchihaDNA.Disabled = false
    wait(40)
    game.ServerScriptService.UchihaDNA.Disabled = true
end
if un == 32 then
    game.ServerScriptService.SteelDNA.Disabled = false
    wait(40)
    game.ServerScriptService.SteelDNA.Disabled = true
end


2 answers

Log in to vote
1
Answered by
quinzt 201 Moderation Voter
4 years ago

if you want it to keep randomly picking a number you should write:

while true do
local num = math.random 1,10
wait(3) --any number
if num == 1 then print("1")
elseif num ==2 then print("2")
--and so on...
Ad
Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

If you want it to constantly pick a number place it in a loop. For example,

while true do
    local num = math.random(1,5)
    if num == 1 then
        print(num)
        wait(2)
    elseif num == 2 then
        print(num)
        wait(2)
    elseif num == 3 then
        print(num)
        wait(2)
    elseif num == 4 then
        print(num)
        wait(2)
    elseif num == 5 then
        print(num)
        wait(2)
    end
end

but it depends on what you really want it to do. Do you want it to just keep picking random numbers? Or do you want it to pick another random number after you press a button? If its the latter, do not place it in a loop.

Answer this question