Hi I’d like to know how to make a number ranged if statement and I was wondering if anyone could help (here’s an example so people can get an idea of what I’m trying to do)
– code example –
if numberSelected == (1 thru 13) then
(function)
end
– end of the example –
id like any help thanks.
You can check if the value is greater than or equal to the minimum number and less than or equal to the maximum number like so:
if numberSelected >= 1 and numberSelected <= 13 then
-- Continue
end
Otherwise, you could utilize NumberRanges to ensure that you’re checking for the same range of numbers if you need to check for it multiple times, adjust the values during runtime, etc.
local newNumberRange = NumberRange.new(1, 13)
if numberSelected >= newNumberRange.Min and numberSelected <= newNumberRange.Max then
-- Continue
end
4 Likes