Examples

Defining a function

function functionName() -- define the function

end -- end the function, sort of like a break point for the function

Everything inside the function before the "end" will execute

Running a function

function functionName() -- define the function

end -- end the function, sort of like a break point for the function

functionName() -- run the function

Loops

local num = 0

function checkNum()
while num < 20 
do
   num = num + 1
   if num == 19
   then
     -- do something and stop the loop
      break
   end
 end
end

Last updated

Was this helpful?