Random Number Help

Hi,

So I’m trying to make a game that tests your luck. To do that, I need to generate two numbers, if the number is one, the door stays open. But if the number is 2, the door slams in your face. The only problem is when the number is 2, the script just doesn’t work. Could anybody help me with this?

Code:

You have the comparison if ranNum == 2 then... nested inside of the other comparison, if ranNum == 1 then...
This makes the code under ranNum==2 never run as it can’t be equal to one and equal to two.
Make sure to end the first one before the second. So that it looks like:

if ranNum == 1 then
[...]
end

if ranNum == 2 theen
[...]
end

Or use an if/else-if or if/else, since there’s only two possibilities you could do

if ranNum == 1 then
[...]
else
[...]
end
4 Likes

@InkBrains mark his post as Solved

So basically, I see that you have your if statement for two inside of your if statement for one. simple error lol. :+1:

let me actually see it first jeez

1 Like

Theen. Sorry i just had to do this lol. But you should use else.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.