Script Editor

The Script Editor in Studio is the primary tool for scripting on Roblox. It's a self-improving environment that can help you write high-impact code, shorten your development time, and iterate on your experiences. It can improve your scripting experience by:

  • Formatting and highlighting syntax in your code.
  • Offering ways to complete phrases in your code as you type.
  • Helping you navigate code by jumping to variable and function declarations.
  • Helping you find and replace code in open scripts or all scripts.
  • Providing you real-time feedback on your code quality and performance.

The Script Editor supports all types of scripts and opens automatically when you create a new script or double-click an existing script in the Explorer window.

Autocomplete

The Script Editor generates code-related information that can improve your programming efficiency. It offers suggestions on how to complete phrases as you type them. Use the up and down arrow keys to browse the suggestions, then press Tab or Enter to accept a suggestion and insert the complete phrase.

The Script Editor is tied to the 3D environment in Studio. If you have a Part in Workspace called CoolRocketShip, then autocomplete suggests CoolRocketShip when you type workspace.cool and indicates that it's a Part.

Autocomplete also offers names for variables and functions that you declare, making it easier to avoid typos and reuse code.

Documentation

The autocomplete pop-up provides documentation and code samples similar to those on the Engine API Reference, providing you with context on an API's usage.

Signature Help

When you type an argument into a function, the autocomplete pop-up also shows the function's signature, providing you with a reference for its parameters and return values.

Code Navigation

The Script Editor provides multiple ways to navigate your variable and function declarations.

Go to Declaration

You can jump to the declaration of a function or variable by right-clicking its call and clicking Go to Declaration. You can also jump to a declaration by holding Ctrl on Windows or on macOS when clicking the call.

Script Function Filter

The Script Function Filter displays a list of functions declared in a script. To open it, right-click anywhere in the editor, then click Script Function Filter. With the list open, you can browse the signatures for each function, filter through them by name, and double-click one to jump to its declaration.

Find and Replace

The Find and Replace widget lets you find and replace code in an open script. The widget supports matching case, matching the whole word, and regular expressions. To open the Find and Replace widget, press Ctrl + F on Windows or + F on macOS.

Find All / Replace All

The Find All / Replace All window lets you find and replace code in all scripts in an place. The window supports matching case, matching the whole word, and regular expressions. To open the Find All / Replace All window, open the View tab and click Find All / Replace All.

Real-Time Feedback

The Script Editor can help you learn Luau faster by providing real-time feedback with the Script Analysis and Output windows.

Script Analysis

The Script Analysis window, accessible from the View tab, performs static analysis on your scripts and displays active errors and warnings. To display only the errors and warnings for the current script, toggle the "Display only current script" checkbox. For more information on the errors and warnings, see the Luau Lang documentation.

Output

The Output window, accessible from the View tab, displays errors captured from running scripts, messages from Roblox engine, messages from calls to print(), and errors from calls to warn(). For information on how to configure it for your workflow, see Output.

Code Assist

Code Assist is an AI assistant that suggests lines or functions of code as you type, helping you code more efficiently and stay focused. Based on contexts from your comment and code, suggestions will be triggered in two ways:

  • Automatically when you pause on a line for a few seconds and the AI model has enough context for a suggestion.
  • Manually with shortcut Alt + on Windows or + on MacOS (you can customize this shortcut).

Press Tab to accept a suggestion, or ignore it by continuing to type. Currently, your script needs to contain at least a few lines of code to trigger a suggestion.

Improving Suggestions

To get more accurate and relevant suggestions, it's recommended that you follow clean coding practices, regardless of AI assistance, and:

  • Break down your code into smaller functions.
  • Use descriptive script names that capture the overall intent of what each script does. For example, name a script SyncCustomSounds instead of just Sounds.
  • Assign descriptive names for parameters, functions, and scripts. For example, name a part GreenSphere instead of simply grs, or name a function generateSphere() instead of gen(). Using named functions versus anonymous functions can also produce better hints.
  • Consistently include well-written comments that describe the task you're implementing and what the inputs/outputs should be.
    • Consider including some sample calls with expected results in comments.
    • Suggest how to solve a problem, for instance -- Use raycast.
    • Use the exact function or variable name you defined, for example -- Create 10 greenSphere objects instead of -- Create 10 spheres.
  • If you're a novice scripter, start with basic projects such as "make the player jump when they touch the part" or use the tool to generate small code snippets that you can expand upon as your knowledge grows.

Limitations

The tool helps automate basic coding tasks but it does not always suggest perfect code. Known limitations include:

  • Manual triggering does not always force-generate a suggestion.
  • Suggestions are machine learned from a corpus of code and can thus reflect some limitations of the code they're trained on. For example, suggestions may not use newer APIs in favor of older APIs, or they may use Lua instead of Luau.
  • The tool may generate incorrect or misleading information that is not useful for your purpose.
  • Internal filters attempt to block offensive language, but they're not all-encompassing and there's a possibility the tool may generate offensive or biased information.
  • The suggestions may be the same, similar, or different among users, even with the same prompts. Your code, however, will never be shared with others.
  • The suggestion may be incomplete due to the limited length of output from the learning models.
  • There's a daily cap for the number of suggestions and, once the cap is reached, you will get no suggestions until the next day.

Code Privacy

Currently, Roblox does not use any non-public data to train the learning models. The tool only uses a small subset of free marketplace assets for tuning large language models and the subset has passed various checks for quality and safety filters.

Furthermore, all suggestions are generated by the AI model and do not transfer from one user to another. Since your code is not used for model training, it won't be suggested to other users of Code Assist, with the one exception of code being posted to free marketplace items.

Multi-Cursor

The Script Editor supports the use of multiple cursors to make edits simultaneously. You can add cursors based on your needs with a mouse click or keyboard shortcut. The initial cursor is called the primary cursor, and additional cursors are called secondary cursors. All lines with a cursor are highlighted. The edits at the primary cursor copy to the secondary cursors. Widgets such as Autocomplete appear on the primary cursor but not the secondary cursors.

In multi-cursor editing, each edit counts as one edit even if you have multiple cursors. If you undo or redo an edit while using multi-cursor editing, the undo or redo applies to all cursors. The standard keyboard shortcuts for editing in Script Editor, such as indenting code, toggling comments, and deleting lines, all work with multi-cursor editing.

To remove all secondary cursors, exit multi-cursor editing, and return to the primary cursor, press Esc.

Adding Cursors

You can add cursors with a combination of keyboard shortcuts and mouse maneuvers. Cursors merge if they occupy the same space, such as if you add cursors with arrow keys or delete all the characters between cursors.

At Mouse Location

To add a cursor at your mouse:

  1. Press and hold Alt on Windows or on macOS.

  2. Click in the Script Editor where you want to add the cursor.

With Mouse Drag

To add a cursor to a selection of text:

  1. Press and hold Alt on Windows or on macOS.

  2. Click and drag your mouse over the selection of text.

Above and Below Primary Cursor

To add a cursor directly above or below the primary cursor:

  1. Press and hold Ctrl + Alt on Windows or + on macOS.

  2. Press the up and down arrows.

To All Matching Selections

To add a cursor to all matching selections:

  1. Select the code that you want to search for matches of.

  2. Press Shift + Alt + L on Windows or Shift + + L on macOS.

To Next Matching Selection

To add a cursor to the next matching selection:

  1. Select the code that you want to search for matches of.

  2. Press Ctrl + D on Windows or + D on macOS.

  3. Continue pressing Ctrl/ + D until you've selected all the next matches that you want.

To Previous Matching Selection

To add a cursor to the previous matching selection:

  1. Select the code that you want to search for matches of.
  2. Open the Quick Open Window with Ctrl + P on Windows or + P on macOS.
  3. In the Quick Open Window, type >Select previous occurrence.
  4. The previous occurrence selects and has a secondary cursor.

You can also create a shortcut of your choice by opening the Customize Shortcuts window in File > Advanced > Customize Shortcuts and editing the shortcut for "Select previous occurrence".

To Selected Line Ends and Selection End

To add cursors at the end of each line in a multi-line selection and at the end of the selection:

  1. Select the lines of code.

  2. Press Shift + Alt + I on Windows or Shift + + I on macOS.

Removing Cursors

You can remove cursors with a combination of keyboard shortcuts and mouse maneuvers. To remove all secondary cursors and exit multi-cursor editing, press Esc or click anywhere in the Script Editor.

At Mouse Location

To remove a cursor:

  1. Press and hold Alt on Windows or on macOS.

  2. Click the cursor you want to remove.

Most Recently Added

To remove the most recently added cursor, press Ctrl + U on Windows or + U on macOS.

Copying and Pasting Cursors

Copying a selection of text includes the cursors within it. The behavior of the paste depends on the number of cursors at the source and the number of cursors at the destination:

  • If the number of cursors are the same, then each copied cursor pastes to each corresponding destination cursor.

  • If the number of cursors are different, then each cursor at the destination receives the entire paste with each copied cursor as a new line.

Customization

The Script Editor offers a wide array of settings, so you can customize it to suit your preferences and workflows. For example, you can configure aesthetics such as the font family and size, formatting behavior, and colors for syntax highlighting. You can also toggle features such as Autocomplete, Signature Help, and Script Analysis.

To open the settings, click File, click Studio Settings, then click Script Editor. You can also press Alt + S on Windows or + S on macOS.

Keyboard Shortcuts

The Script Editor has the following keyboard shortcuts. You can also access many commands by right-clicking anywhere in the editor.

General

Command Windows macOS
Close Script Ctrl + W + W
Reopen Last Closed Script Ctrl + Shift + T + Shift + T
Quick Open, Go to File... Ctrl + P + P
Show in Explorer Ctrl + Alt + K + + K
Studio Settings Alt + S + S

Basic Editing

Command Windows macOS
Undo Ctrl + Z + Z
Redo Ctrl + Y Shift + + Z
Cut Ctrl + X + X
Copy Ctrl + C + C
Paste Ctrl + V + V
Select All Ctrl + A + A
Format Selection Alt + Shift + F + Shift + F
Indent Ctrl + ] + ]
Unindent Ctrl + [ + [
Toggle Comment Ctrl + / + /
Expand All Folds Ctrl + E + E
Collapse All Folds Ctrl + Shift + E + Shift + E
Delete Line Ctrl + Shift + K + Shift + K
Delete to Start of Line Ctrl + Shift + Backspace + Delete
Move Line Up/Down Alt + Up/Down Option+ + Up/Down
Go to Declaration Ctrl + F12 + F12
Open Script Function Filter Alt + F + F

Multi-Cursor Editing

Command Windows macOS
Add or Remove Cursor at Mouse Location Alt + click + click
Add Cursor with Mouse Drag Alt + click and drag + click and drag
Add Cursor Above Primary Cursor Ctrl + Alt + + +
Add Cursor Below Primary Cursor Ctrl + Alt + + +
Add Cursor to All Matching Selections Shift + Alt + L Shift + + L
Add Cursor to Next Matching Selection Ctrl + D + D
Add Cursors to Selected Line Ends and Selection End Shift + Alt + I Shift + + I
Remove Most Recently Added Cursor Ctrl + U + U

Display

Command Windows macOS
Zoom In Ctrl + = + =
Zoom Out Ctrl + - + -
Reset Script Zoom Ctrl + 0 + 0