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

[Answered] How do you get 3 different numbers between 1 and 6??

Asked by 5 years ago
Edited 5 years ago

I'm trying to get 3 different numbers between 1 and 6. I have no idea why it's not working.

math.randomseed(tick())
local num = math.random(1,6)
print(num)

wait(0.5)
math.randomseed(tick())
local numb = math.random(1,6)
print(numb)

wait(0.7)
math.randomseed(tick())
local number = math.random(1,6)
print(number)


while true do
    wait()
    if number == numb then
        wait(1)
        math.randomseed(tick())
        local numb = math.random(1,6)
    elseif number == num then
        wait(1)
        math.randomseed(tick())
        local num = math.random(1,6)
    elseif num == numb then
        wait(1)
        math.randomseed(tick())
        local num = math.random(1,6)
    else
        break
    end
end

any ideas, thanks in advance.

math.randomseed(tick())
local num = math.random(1,6)
print(num)

wait(0.5)
math.randomseed(tick())
local numb = math.random(1,6)
print(numb)

wait(0.7)
math.randomseed(tick())
local number = math.random(1,6)
print(number)

while true do
    wait()
    if number == numb then
        wait(1)
        math.randomseed(tick())
        local numb = math.random(1,6)
        print(numb.."numb")
    elseif number == num then
        wait(1)
        math.randomseed(tick())
        local num = math.random(1,6)
        print(num.."num")
    elseif num == numb then
        wait(1)
        math.randomseed(tick())
        local num = math.random(1,6)
        print(num.."num1")
    else
        break
    end
end

https://imgur.com/a/ejCkFgz

As can be seen in the screenshot, num and numb = the same number so it went to the if statement and changed the number to 2 but then kept going??

0
What are you trying to do here? vBaRaAx02 1 — 5y
0
Get 3 different numbers (it's for a voting system) Hypoxic1 8 — 5y
0
Well the script seems fine for me, Is there any error messages? vBaRaAx02 1 — 5y
0
nope Hypoxic1 8 — 5y
0
Before I put prints in the loop and for some reason it just ignored the if statement and kept randomising the number Hypoxic1 8 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
math.randomseed(tick())
local num = math.random(1,6)
print(num)

wait(0.5)
math.randomseed(tick())
local numb = math.random(1,6)
print(numb)

wait(0.7)
math.randomseed(tick())
local number = math.random(1,6)
print(number)

while true do
    wait()
    if number == numb then
        wait(1)
        math.randomseed(tick())
        numb = math.random(1,6)
        print(numb.."numb")
    elseif number == num then
        wait(1)
        math.randomseed(tick())
        num = math.random(1,6)
        print(num.."num")
    elseif num == numb then
        wait(1)
        math.randomseed(tick())
        num = math.random(1,6)
        print(num.."num1")
    else
        break
    end
end

This is the answer (facepalm) I put local in front of the variables in the while true just delete them and it works sorry for wasting your time.

Ad

Answer this question