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 autocomplete 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 real-time feedback on your code quality and performance.
The Script Editor generates code-related information that can improve your programming efficiency.
Autocomplete offers suggestions on how to complete phrases as you type them. Use the ↑ and ↓ keys to browse the suggestions, then press Tab or Enter to accept a suggestion and insert the complete phrase.
Autocomplete offers names for variables and functions that you declare, helping you avoid typos.
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.
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.
You can jump to the declaration of a function or variable by holding Ctrl on Windows or ⌘ on macOS when clicking the call, or by right-clicking its call and clicking Go to Declaration.
The Script Function Filter displays a list of all functions declared in a script. To open it, press AltF on Windows or ⌥F on macOS. 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.
The Find/Replace widget lets you find and replace code in an open script. The widget supports matching case, matching the whole word, and searching by regular expressions. To open it, press CtrlF on Windows or ⌘F on macOS.
The Script Analysis window, accessible from the View tab, performs static analysis on your scripts and displays active errors and warnings. For more information on the errors and warnings, see the Luau linting documentation.
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 details on configuring it for your workflow, see Output Window.
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.
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.
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.
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.
The Script Editor supports usage 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.
- Edits that you make at the primary cursor copy to the secondary cursors. Each edit counts as one action, so undo/redo of an edit applies to all cursors.
- Widgets such as autocomplete appear on the primary cursor but not the secondary cursors.
- All of the standard keyboard shortcuts for script editing work with multi-cursor editing, including code indentation, toggling comments, and deleting lines.
The following table summarizes multi-cursor workflows and their shortcuts.
|Add/Remove Cursor at Mouse Location||Alt + click||⌥ + click|
|Remove Most Recently Added Cursor||CtrlU||⌘U|
|Add/Modify Cursor on Mouse Drag||Alt + drag||⌥ + drag|
|Add Cursor Above/Below||CtrlAlt↑ / CtrlAlt↓||⌘⌥↑ / ⌘⌥↓|
|Add Cursor to Next Matching Selection||CtrlD||⌘D|
|Add Cursor to Every Matching Selection||ShiftAltL||Shift⌥L|
|Column/Block Select||ShiftAlt + drag||Shift⌥ + drag|
|Split Selections Into Lines||ShiftAltI||Shift⌥I|
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.
To add a cursor at your mouse pointer location:
Hold Alt on Windows or ⌥ on macOS.
Click where you want to add the cursor.
You can drag the mouse to add a cursor to a selection, split a multi-line selection into lines, or select columns and blocks of code/whitespace.
To add a cursor to a selection of code through dragging:
Hold Alt on Windows or ⌥ on macOS.
Click and drag your mouse over the selection of code.
To split a multi-line selection into lines and add a cursor at the end of each line, press ShiftAltI on Windows or Shift⌥I on macOS.
To select columns and blocks of code or whitespace, drag the mouse while holding ShiftAlt on Windows or Shift⌥ on macOS. As you drag, a cursor will be added on each highlighted line.
To add a cursor directly above or below the primary cursor:
Press and hold CtrlAlt on Windows or ⌘⌥ on macOS.
Press the ↑ or ↓ arrows.
You can add cursors to all matches of a selection or to the next/previous match, and optionally toggle whether matches are case-sensitive and/or match the whole word.
To add a cursor to all matches of a selected portion:
Select the code that you want to search for matches of.
Press ShiftAltL on Windows or Shift⌥L on macOS.
To add a cursor to the next matching selection:
Select the code that you want to search for matches of.
Press CtrlD on Windows or ⌘D on macOS.
Continue pressing CtrlD or ⌘D until you've selected all the next matches that you want.
There is no default shortcut for adding a cursor to the previous matching selection, but you can add your own:
Open File → Advanced → Customize Shortcuts.
In the shortcuts window, locate Select previous occurrence.
Double-click the action's Shortcut field and enter your own custom key combination, such as ShiftCtrlD to pair alongside "next" matching's default of CtrlD.
Confirm your setting by clicking OK in the bottom-right corner of the window.
For each of the matching-related workflows above, you can match case and/or whole word as follows:
Open the Find/Replace tool (CtrlF on Windows or ⌘F on macOS).
Use the toggle buttons to choose if a matched selection should be case-sensitive and/or match the whole word only.
You can remove cursors with the following keyboard shortcuts and mouse maneuvers. Alternatively, you can exit multi-cursor editing by pressing Esc.
To remove a cursor:
Press and hold Alt on Windows or ⌥ on macOS.
Click the cursor you want to remove.
To remove the most recently added cursor, press CtrlU on Windows or ⌘U on macOS.
Copying a selection of code 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.
Pressing enter/return will auto-indent each cursor at the new line relative to the previous line. If the previous line starts with an incomplete block, the formatter will try to complete it.
The Script Editor has the following keyboard shortcuts. You can also access many commands from the Script tab which appears in the Studio toolbar whenever you're viewing or editing a script.
|Reopen Last Closed Script||CtrlShiftT||⌘ShiftT|
|Show Script in Explorer||CtrlAltK||⌘⌥K|
|Reset Script Zoom||Ctrl0||⌘0|