function

A function is a basic Lua type. A function is a module of code that accomplish a specific task.

Client.Action1 = function()
  -- everything in that function is executed when action 1 is triggered
  if Player.IsOnGround then
    Player.Velocity.Y = 30
  end
end

A function can return one or several values:

-- a function that returns one value
local f1 = function()
  return "hello"
end

-- call f1
local value = f1()
print(value) -- prints "hello"

-- a function that returns two values
local f2 = function()
  return "hello", "world"
end

-- call f2
local v1, v2 = f2()
print(v1 .. " " .. v2) -- prints "hello world"

A function can take parameters:

-- a function that returns one value
local f = function(message)
  print(message)
end

-- call f
f("hello world") -- prints "hello world"