Roblox Wiki
Roblox Wiki
Tutorial page
This article is an easy tutorial.

What are keywords?

Keywords are special words that cannot be used as variable names or function names, and control the flow of the script.

What are some keywords?

The keywords in lua are:

  • if
  • else
  • elseif
  • export
  • for
  • while
  • break
  • continue
  • repeat
  • until
  • next
  • not
  • true
  • false
  • then
  • end
  • function
  • local
  • or
  • and
  • do
  • self

List is not complete.

Keywords in action

An example of an if statement:

if true then -- Using keywords ''if'', ''true'', and ''then''
elseif false then -- Using keywords ''elseif'', ''false'', and ''then''
    -- Don't do anything
else -- Using keyword ''else''
end -- Using keyword ''end''

An example of a for loop:

for i=1, 10 do -- Using keywords ''for'' and ''do''

An example of a do block:

do -- Using keyword ''do''

An example of a while loop:

while true do -- Using keywords ''while'', ''true'', and ''do''
    break -- Using keyword ''break''
end -- Using keyword ''end''

An example of using and, or, and not:

local a = false and 0 or not false and 1 --Using keywords ''local'', ''false'', ''and'', ''or'', and ''not''

This code produces an error:

local if = 1

because the variable name is a keyword.