Roblox: General Scripting Cheat Sheet: by Via
Roblox: General Scripting Cheat Sheet: by Via
Model A container for Parts. math.abs(n) Returns absolute value of A string is a collection of characters, or text. An
Folder A container for Scripts and value n. example of a string property is the Name
objects. property. Read all string manipulation functions
math.sqrt(n) Returns square root of n.
here.
Script A container for Lua source code.
math.pi Approx equal to 3.14159
LocalScri A Script that runs its code on a
Tables
pt client. It's important to work out problems by hand
before translating their solutions into code. local list = {1, 2, 3}
Algebra is necessary for success. Read about
Basic math functions local firstNum = list[1]
all math functions here.
Operation Description list[2] = 4
print("There are " .. #list .. "
a + b Adds a and b. String functions
numbers")
a - b Subtract a and b. Operation Description local total = 0
a * b Multiply a and b. a .. b Combine two for i = 1, #list do
strings. total = total + list[i]
a / b Divides a by b.
Function Description end
a % b Remainder of a divided
string.len(str) Returns length of print("The total is " .. total)
by b.
str.
Tables are a collection of values. They are
Function Description
string.upper(str) Returns str in defined using curly braces {} with values
math.random(n) Returns random number separated by commas. Access the values
upper-case.
from 1 to n (no inside using square brackets []. Tables are
string.lower(str) Returns str in
negatives). sometimes called arrays. Use a for loop to
lower-case.
math.random(a, Returns random number work with all items in a table individually. The
string.reverse(str) Returns str in :GetChildren() method returns a table of
b) from a to b.
reverse. children in an object.
math.max(...) Returns the largest
string.rep(str, n) Returns str
number.
repeated n times
math.min(...) Returns the smallest
number.
game Parent of all game services. How do I copy a preexisting object? function onTouch(part)