Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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??

5 comments

0

What are you trying to do here?

0

Get 3 different numbers (it's for a voting system)

0

Well the script seems fine for me, Is there any error messages?

0

nope

0

Before I put prints in the loop and for some reason it just ignored the if statement and kept randomising the number

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.