So they way I’m doing it is by looping until its smaller or equal to the smaller number but looping takes too much time for mutliple numbers being effected so is there a more efficient and faster way for this?
local max = 21
local min = 4
max -= min
until max <= min
using that loop is efficient, just remove the task.wait() as it unnecessarily slows it down.
max -= min * math.floor(max/min)
floor(max/min) is how many times min goes into max.
Pretty sure you can also just do
max = 21 % 4.
local function subtractTillLessThan(max : number, min : number) : number
return max - (math.floor(max / min) * min)
Which is essentially the same as using the modulo operator.