Modulos utlizes division, so your understanding of dividing is essential for understanding this topic.
A "Modulo" in Lua can simply be shown as [%], also known as the percent sign.
How Does It Work?
(a.) When using modulos, you must always have a value on the left and right side of the [%]
(b.) The code will then take the left number and divide it by the right number
(c.) After being divided, Lua will return the remainder that has been left behind from the equation.
(a.) 5%2 -- This example modulo equation will be used throughout examples a-c (b.) 5/2 = 2 remainder 1 -- 5 is divided by 2, leaving 2 and a remainder of 1 (c.) 1 -- Modulo only pays attention to the remainder, so the 2 is ignored This means that 5%2 = 1
10%2 = 0 1%2 = 1 16%5 = 1 100%25 = 0 7%4 = 3
That's all this lesson has to offer! I hope you have a better understanding of Modulos now!
Med Written By LegendaryFrosts
See LegendaryFrosts's profile on Roblox