Script Tab

*เนื้อหานี้จะพร้อมใช้งานในภาษาที่คุณเลือกในเร็วๆ นี้

The Script tab contains tools for writing and testing scripts. You can only access this tab when you're viewing or editing a script.

Script tab indicated in Studio toolbar

The Navigate section lets you quickly jump between any open script.

ActionShortcutDescription
BackShiftCtrl- (Windows)
Shift- (Mac)
Navigates to the previous open script.
FwdShiftCtrl= (Windows)
Shift= (Mac)
Navigates to the next open script.

Edit

The Edit section lets you search and edit any part of the script, as well as select instances within the Explorer window for bulk actions. See Studio Shortcuts for default shortcuts tied to these actions.

Edit tools indicated in Script tab
ActionDescription
Find

Opens a pop-up menu with the following tools:

  • Find — Locates all instances of your input in the script.
  • Find Next — Locates the next match found in the "Find" widget.
  • Find Previous — Locates the previous match found in the "Find" widget.
  • Find All — Locates all instances of your input within a place, even outside of the currently selected script.
  • Go to Line — Navigates to a specific line within the script.
  • Quick Open — Searches all instances in the Explorer window.
  • Quick Open Actions — Searches all Studio actions.
  • Open Script Function Filter — Searches all functions within the active script and its required module scripts.
ReplaceLets you replace one (or all) matches in a script with a new string.
Select

Opens a pop-up menu with the following tools:

  • Select All — Selects all contents of a script.
  • Select Children — Selects all descendants of a selected instance in the Explorer window.

Format

The Format section lets you format sections or the entirety of the script for readability. The dropdown lets you select either Format Selection or Format Document.

Format options indicated in Script tab
ActionShortcutDescription
Format SelectionAltShiftF (Windows)
ShiftF (Mac)
Formats the currently selected portion of the script with proper layout and indentation.
Format DocumentFormats the entire script regardless of the current selection.

Pausing & Resuming Scripts

While playtesting, the Pause Scripts and Resume Scripts buttons are useful for pausing both scripts and rendering, without pausing physics.

Pause Scripts and Resume Scripts buttons available during playtesting in Studio.

Debugging Tools

The Debugger section lets you control the debugger.

Debugging tools indicated in Script tab
ActionShortcutDescription
Step IntoF11Moves the debugger into the function on the current line. If there is no function on the current line, the debugger moves to the next line.
Step OverF10Moves the debugger to the next line of code, not moving into functions.
Step OutShiftF11Moves the debugger out of the current function and to the next line of code after the function was initially called. If the current line is not inside a function, the debugger moves to the next line.

In the neighboring Debug Errors section, you can opt to treat script errors as impromptu breakpoints.

ActionDescription
NeverDisables impromptu script debugging.
On All ExceptionsFlags all errors, even those occurring within pcall.
On Unhandled ExceptionsOnly flags errors that occur in unprotected mode; the debugger ignores errors occurring within pcall .

Other Actions

The Actions section at the furthest right contains miscellaneous script actions.

ActionShortcutDescription
Go to Script ErrorNavigates the cursor to the first instance of an error within your script.
Reload ScriptCtrlR (Windows)
R (Mac)
Applies any changes that have been made to a script to the active playtest. The changes are not saved to the script outside of the playtest unless your Studio settings are set to auto-save runtime script changes or you confirm to save the changes upon stopping the playtest. This action is only available while playtesting.
CommitCommits any changes to the script so the updated script is available to other developers within your team. This action is only available during collaborative sessions.
Toggle CommentCtrl/ (Windows)
/ (Mac)
Toggles whether a line of script is a comment or not.
Expand All FoldsCtrlE (Windows)
E (Mac)
Expands all collapsed folds in the script.
Collapse All FoldsShiftCtrlE (Windows)
ShiftE (Mac)
Collapses all foldable sections of the script.