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