Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
5

How to check if the number generated is a multiple of 5? [closed]

Asked by 5 years ago
local number = math.random(20,80)
if number == 20 or number == 80 then
    print("Scouted stat limit reached")
end

I wonder if there is a more efficient way to find if the number is 20,25, 30, 35, 40, 45, 50, 55, 60, 65 ,70, 75, or 80. Typing a lot of if and or statements would take quite a while.

0
divide the number by 5 and check if there's a decimal zor_os 70 — 5y
2
Did you know that you could do a google search and find this out in 10 seconds or less? User#21908 42 — 5y

Locked by User#19524

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
7
Answered by 5 years ago

You can simply use the modulus operator. Example:

if number % 5 == 0 then
--code
end

It just divides by the number you provide and returns the remainder. If the remainder is 0 you know that it is divisible by five or whatever number you put in. I hope this helps and have a great day scripting!

Ad