luacheat sheet
luacheat sheet
press ctrl+f to search for something specific
reference sheet
print() - Outputs a message to the output console
wait() - Pauses the execution of the script for a specified amount of time
string.sub() - Returns a specific substring of a string
math.abs() - Returns the absolute value of a number
table.sort() - Sorts the elements of a table
Instance.new() - Creates a new instance of a class
game.GetService() - Returns a service object
script.Parent - Returns the parent object of a script
_G - Global variable table
math.pi - The constant value of pi
Enum - Table containing enumeration values
Color3 - Table containing color values
Vector3 - Table for 3D vectors
CFrame - Table for Coordinate Frame values
UDim2 - Table for 2D size and position values
game.Players - Table of all players in the game
game.Workspace - Table of all objects in the game's workspace
script.Parent - The parent object of a script
Instance properties - Properties of an object, such as Position or Parent
Instance methods - Methods that can be called on an object, such as :Clone() or :BreakJoint()
Events - Events that can be connected to, such as Player.PlayerAdded or Part.Touched
Enumerations - Constants for sets of named values, such as Enum.Material.Plastic
pre-written examples
--Example of a basic function
function printHello()
print("Hello, World!")
end
--Example of a function with parameters
function addNumbers(num1, num2)
local sum = num1 + num2
print(sum)
end
--Example of a for loop
for i = 1, 10 do
print(i)
end
--Example of a while loop
local count = 0
while count < 5 do
print(count)
count = count + 1
end
--Example of a basic array
local myArray = {1, 2, 3, 4, 5}
--Example of an array with mixed data types
local mixedArray = {1, "hello", false, 5.5}
--Example of an array with keys and values
local keyValueArray = {["name"] = "John", ["age"] = 25}