I'm trying to do a thing for example if the number is 1, it would round the the factor of 4 which would be 4. Or for example 7, it would round to the nearest factor of 8. Is there A way to do this within ROBLOX scripting?
local function roundNumberToFactor(number, factor) return number + (factor - (number % factor)) end
This rounds it up to the highest nearest factor of the number. If you want it to take it to the absolute nearest factor of the number:
local function roundNumberToFactor(number, factor) if(number % factor > factor/2) then return number + (factor - (number % factor)) else return number - (number % factor) end end
However this would take 1 to 0 and not 4 as you asked, so I don't know if this helps or not.
math.floor()