\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Ozzypig (Ozzypig)} \pdfinfo{ /Title (roblox-general-scripting.pdf) /Creator (Cheatography) /Author (Ozzypig (Ozzypig)) /Subject (Roblox: General Scripting Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{DE302A} \definecolor{LightBackground}{HTML}{FCF2F1} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Roblox: General Scripting Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Ozzypig (Ozzypig)} via \textcolor{DarkBackground}{\uline{cheatography.com/25526/cs/6711/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Ozzypig (Ozzypig) \\ \uline{cheatography.com/ozzypig} \\ \uline{\seqsplit{ozzypig}.com} \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 25th January, 2016.\\ Updated 24th January, 2017.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{x{1.09494 cm} x{3.88206 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Essential Objects}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Class}} & {\bf{Description}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Part & A physical brick in the world. \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} Model & A container for Parts. \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} Folder & A container for Scripts and value objects. \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} Script & A container for {\emph{Lua}} source code. \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} \seqsplit{LocalScript} & A Script that runs its code on a client. \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.04057 cm} x{2.93643 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Basic math functions}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Operation}} & {\bf{Description}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `a + b` & Adds `a` and `b`. \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} `a - b` & Subtract `a` and `b`. \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} `a * b` & Multiply `a` and `b`. \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} `a / b` & Divides `a` by `b`. \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} `a \% b` & Remainder of `a` divided by `b`. \tn % Row Count 7 (+ 2) % Row 6 \SetRowColor{LightBackground} {\bf{Function}} & {\bf{Description}} \tn % Row Count 8 (+ 1) % Row 7 \SetRowColor{white} \{\{noshy\}\}`math.random(n)` & Returns random number from `1` to `n` (no negatives). \tn % Row Count 11 (+ 3) % Row 8 \SetRowColor{LightBackground} \{\{noshy\}\}`math.random(a, b)` & Returns random number from `a` to `b`. \tn % Row Count 13 (+ 2) % Row 9 \SetRowColor{white} \{\{noshy\}\}`math.max(...)` & Returns the largest number. \tn % Row Count 15 (+ 2) % Row 10 \SetRowColor{LightBackground} \{\{noshy\}\}`math.min(...)` & Returns the smallest number. \tn % Row Count 17 (+ 2) % Row 11 \SetRowColor{white} \{\{noshy\}\}`math.floor(n)` & Rounds `n` down. \tn % Row Count 19 (+ 2) % Row 12 \SetRowColor{LightBackground} \{\{noshy\}\}`math.ceil(n)` & Rounds `n` up. \tn % Row Count 21 (+ 2) % Row 13 \SetRowColor{white} \{\{noshy\}\}`math.abs(n)` & Returns \{\{link="https://www.mathsisfun.com/numbers/absolute-value.html"\}\}absolute value\{\{/link\}\} of `n`. \tn % Row Count 26 (+ 5) % Row 14 \SetRowColor{LightBackground} \{\{noshy\}\}`math.sqrt(n)` & Returns \{\{link="http://www.mathsisfun.com/algebra/square-root.html"\}\}square root\{\{/link\}\} of `n`. \tn % Row Count 31 (+ 5) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.04057 cm} x{2.93643 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Basic math functions (cont)}} \tn % Row 15 \SetRowColor{LightBackground} \{\{noshy\}\}`math.pi` & Approx equal to `3.14159` \tn % Row Count 2 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{It's important to work out problems by hand before translating their solutions into code. \{\{link="http://www.mathsisfun.com/algebra/introduction.html"\}\}Algebra\{\{/link\}\} is necessary for success. \{\{link="http://wiki.roblox.com/index.php?title=Function\_dump/Mathematical\_functions"\}\}Read about all math functions here.\{\{/link\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.18988 cm} x{2.78712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{String functions}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Operation}} & {\bf{Description}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \{\{noshy\}\}`a .. b` & Combine two strings. \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} {\bf{Function}} & {\bf{Description}} \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \{\{noshy\}\}`string.len(str)` & Returns length of `str`. \tn % Row Count 5 (+ 2) % Row 4 \SetRowColor{LightBackground} \{\{noshy\}\}`string.upper(str)` & Returns `str` in upper-case. \tn % Row Count 7 (+ 2) % Row 5 \SetRowColor{white} \{\{noshy\}\}`string.lower(str)` & Returns `str` in lower-case. \tn % Row Count 9 (+ 2) % Row 6 \SetRowColor{LightBackground} \{\{noshy\}\}`string.reverse(str)` & Returns `str` in reverse. \tn % Row Count 11 (+ 2) % Row 7 \SetRowColor{white} \{\{noshy\}\}`string.rep(str, n)` & Returns `str` repeated `n` times \tn % Row Count 13 (+ 2) % Row 8 \SetRowColor{LightBackground} \{\{noshy\}\}`string.sub(str, a, b)` & Return sub-string of `str` from `a` to `b`. \tn % Row Count 15 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{A {\bf{string}} is a collection of characters, or text. An example of a string property is the `Name` property. \{\{link="http://wiki.roblox.com/index.php?title=Function\_dump/String\_manipulation"\}\}Read all string manipulation functions here.\{\{/link\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Tables}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{local}} list = \{1, 2, 3\} \newline {\bf{local}} firstNum = list{[}1{]} \newline list{[}2{]} = 4 \newline print("There are " .. \#list .. " numbers") \newline \newline {\bf{local}} total = 0 \newline {\bf{for}} i = 1, \#list {\bf{do}} \newline ~~~total = total + list{[}i{]} \newline {\bf{end}} \newline print("The total is " .. total)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Tables are a collection of values. They are defined using curly braces \{\} with values separated by commas. Access the values inside using square brackets {[}{]}. Tables are sometimes called {\bf{arrays}}. Use a {\bf{for}} loop to work with all items in a table individually. The :GetChildren() method returns a table of children in an object.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.64241 cm} x{3.33459 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Constants}} \tn % Row 0 \SetRowColor{LightBackground} \{\{noshy\}\}`game` & Parent of all game services. \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \{\{noshy\}\}`workspace` & Container for all bricks and models are stored. \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \{\{noshy\}\}`script` & The currently running script. \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Finding Objects}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{workspace.Part:Destroy() \newline \newline print(script.Parent.Name) \newline \newline game.ServerStorage.Tree:Clone()} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Use a period to access an object's children. Use .Parent to access an object's parent. Use constants like game, workspace, and script to identify objects in the hierarchy.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Creating objects}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{How do I create an object?} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Using `Instance.new(class)` and setting the parent:\{\{nl\}\}`object.Parent = parent`} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{How do I access an object's properties?} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Use a period (`.`):\{\{nl\}\}`print(object.Name)`} \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{How do I set an object's properties?} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Use a period (`.`) and equals sign (`=`):\{\{nl\}\}`part.Transparency = .5`} \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{How do I destroy an object?} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Using `object:Destroy()`} \tn % Row Count 10 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{How do I copy a preexisting object?} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Using `object:Clone()` and setting the parent:\{\{nl\}\}`newTree = workspace.Tree:Clone()\{\{nl\}\}newTree.Parent = workspace`} \tn % Row Count 14 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.18988 cm} x{2.78712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{General Object Functions}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Method name}} & {\bf{Description}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \{\{noshy\}\}`:FindFirstChild(name)` & Return a child with `name` or {\bf{`nil`}} if it doesn't exist. \tn % Row Count 4 (+ 3) % Row 2 \SetRowColor{LightBackground} \{\{noshy\}\}`:WaitForChild(name)` & Pauses until a child with a name exists and returns it. \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} \{\{noshy\}\}`:IsA(className)` & Return whether the object is a certain type of object. \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} \{\{noshy\}\}`:Clone()` & Makes and returns a copy of an object. \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} \{\{noshy\}\}`:Destroy()` & Permanently delete an object. \tn % Row Count 14 (+ 2) % Row 6 \SetRowColor{LightBackground} \{\{noshy\}\}`:GetChildren()` & Return a list of an object's children. \tn % Row Count 16 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{These are functions (aka methods) for all classes of ROBLOX objects. \{\{link="http://wiki.roblox.com/index.php?title=API:Class/Instance"\}\}Read about all methods here.\{\{/popup\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Event basics}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{function}} onTouch(part) \newline ~~~print(part.Name .. " touched me!") \newline {\bf{end}} \newline workspace.Part.Touched:connect(onTouch)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Events are specific occurrences relating to objects. When an event {\bf{fires}}, or occurs, all connected functions are called.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.74195 cm} x{3.23505 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Basic functions}} \tn % Row 0 \SetRowColor{LightBackground} \{\{noshy\}\}`wait(n)` & Wait `n` seconds then continue. \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \{\{noshy\}\}`print(...)` & Display something in the Output window. \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Variables}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{local}} myScore = 5 \newline myScore = myScore + 1 \newline print(myScore) \newline \newline {\bf{local}} myName = "Ozzy" \newline print("My name is " .. myName)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Variables store data of any kind - numbers, strings, tables, objects or {\bf{nil}} (nothing). A {\bf{local}} variable is only accessible in the block of code it is defined in.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{`If` statements}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{if}} \seqsplit{workspace:FindFirstChild("Tree")} {\bf{then}} \newline ~~~print("There is a tree here.") \newline {\bf{end}} \newline \newline {\bf{if}} coins \textless{} 5 {\bf{then}} \newline ~~~print("You need more money.") \newline {\bf{else}} \newline ~~~print("You have enough money!") \newline {\bf{end}} \newline \newline {\bf{if}} player.Name == "Jake" {\bf{then}} \newline ~~~print("You are an awesome guy, Jake") \newline {\bf{elseif}} player.Name == "Sally" {\bf{then}} \newline ~~~print("You are a sweetheart, Sally") \newline {\bf{else}} \newline ~~~print("You are a pretty cool person") \newline {\bf{end}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{If statements will run their code if the value between {\bf{if}}/{\bf{then}} is true (or not {\bf{nil}}). They can one an {\bf{else}} block, or any number of {\bf{elseif}} blocks.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Loops}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Numeric {\bf{for}} loop} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}\{\{noshy\}\}For counting numerically.\{\{nl\}\}{\emph{Example:}} Count from `1` to `5`:\{\{nl\}\}`{\bf{for}} i = 1, 5 do\{\{nl\}\}~~~print(i)\{\{nl\}\}{\bf{end}}`} \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Generic {\bf{for}} loop} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}\{\{noshy\}\}Most often used for object children.\{\{nl\}\}{\emph{Example:}} Print all children in object:\{\{nl\}\}`{\bf{for}} i, child {\bf{in}} \seqsplit{pairs(object:GetChildren())} {\bf{do}}\{\{nl\}\}~~~print(child.Name)\{\{nl\}\}{\bf{end}}`} \tn % Row Count 11 (+ 6) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{While loop} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}\{\{noshy\}\}Perform code until a condition is false.\{\{nl\}\}{\emph{Example:}} Remove all children named 'Ball'\{\{nl\}\}`{\bf{while}} \seqsplit{object:FindFirstChild("Ball")} {\bf{do}}\{\{nl\}\}~~~object.Ball:Destroy()\{\{nl\}\}{\bf{end}}`} \tn % Row Count 17 (+ 6) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Repeat-until loop} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}\{\{noshy\}\}Perform code once, then again until a condition is true.\{\{nl\}\}{\emph{Ex.:}} Copy objects until there are 5.\{\{nl\}\}`{\bf{repeat}}\{\{nl\}\}~~~newObject = object:Clone()\{\{nl\}\}~~~newObject.Parent = workspace\{\{nl\}\}~~~wait(1)\{\{nl\}\}{\bf{until}} \seqsplit{\#workspace:GetChildren()} \textgreater{}= 5`} \tn % Row Count 25 (+ 8) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Loops are used to {\bf{iterate}}, or repeat code a number of times.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Function examples}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{function}} sayHello() \newline ~~~print("Hello, world") \newline {\bf{end}} \newline sayHello() \newline \newline {\bf{function}} addTwoNumbers(a, b) \newline ~~~print("The sum is:", a + b) \newline {\bf{end}} \newline addTwoNumbers(3, 5) \newline \newline {\bf{function}} calculateSquare(n) \newline ~~~{\bf{return}} n * n \newline {\bf{end}} \newline {\bf{local}} result = calculateSquare(3)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{A function is a named block of code that can be run anywhere in code by {\bf{calling}} it by name. Functions can have {\bf{arguments}} (given values) and/or {\bf{return}} values.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}