so im making this and it is using math.random my question is how do i make it detect more than one number like instead of 1 it could be 1-50 so how do i do this? here is the script.
local EggRan = math.random(1,100)
if EggRan == ???
so im making this and it is using math.random my question is how do i make it detect more than one number like instead of 1 it could be 1-50 so how do i do this? here is the script.
local EggRan = math.random(1,100)
if EggRan == ???
To have more than one condition read by an if statement, you can use one of two keywords:
and. This keyword tells the if statement to check if a and b is true. In the case of this keyword, a and b must both be true in order for the condition to pass. (You can have as many conditions with and as you like, just as long as each condition is separated by and.)or. Tells the if statement to check if either a or b. If a is not true, then check to see if b is true. If neither a or b are true, the condition does not pass. (Like and, you can have as many conditions as you want with or.)In your case, you're checking if a number is between 1 and 50. You would use and:
if EggRan > 1 and EggRan <= 50 then
-- Continue with the code if this condition passes
end
The above code checks for two things, both of which must be true for the condition to pass:
For finding numbers within a range, you should always use math.random().
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
if EggRan > 0 and EggRan < 51 then