Documentation

Unity Spark

Open Unity Spark

Unity Spark

Script window reference

Find the tabs, editor, and save controls in the Unity Spark Script window to read and edit your project's Luau scripts.
Read time 3 minutesLast updated 3 hours ago

The Script window is a code editor for your project's Luau scripts. Each script you open appears in its own tab, with its own unsaved changes.
To open the Script window, do one of the following:
  • Select Add window (+) in any window group and select Script.
  • Double-click a script in the Project window.
  • Select a script in the Project window, then select Open in the Inspector window.
For instructions, refer to Write and attach scripts.

Tab bar

The tab bar contains the following controls.

Control

Description

Script tabsShows one tab for each open script, labeled with the script's name. New scripts that you haven't saved yet show Untitled, then Untitled 2, Untitled 3, and further numbers in tab order. An indicator on a tab marks unsaved changes.
Close (X)Closes the tab. If the script has unsaved changes, Unity Spark asks you to confirm with the Discard unsaved changes? dialog. Select Discard to close the tab and lose the changes.
Agent statusAppears while the assistant works on a script, and names the script it's working on, which might not be the script you have open. For example, the status reads
<agent name> is writing <script name>
, and then
<agent name> wrote <script name>
when it finishes.
Open a script (+)Displays a searchable list of your project's scripts. Select a script to open it in a new tab, or select New script to start a new unsaved script from the default template. If the script is already open, Unity Spark makes its tab active.

Editor

The editor shows the active script's source with Luau syntax highlighting. Use it as follows:
  • Edit the script directly in the editor. Shortly after you stop typing, Unity Spark checks the script for errors and underlines the lines that have errors.
  • Press Ctrl+S (macOS: Cmd+S) to save the script. For a new script that you haven't saved yet, the shortcut opens the Save script as dialog.
If the AI assistant rewrites a script that has unsaved changes, a bar appears at the top of the editor. The bar displays the message
<agent name> rewrote this script. Your unsaved edits are still here.
and contains the following buttons.

Button

Description

Load <agent name>'s versionReplaces your unsaved changes with the assistant's version of the script.
Keep mineKeeps your version in the editor.
When no script is open, the window displays
No script open.
Select Create New Script to start a new script from the default template.

Status bar

The row under the editor has the following controls.

Control

Description

Error messageShows the first error in the script. If there are more,
<number> more
follows it. Hover over or focus the message to display the full numbered list of errors.
Save stateShows one word about the script's state, such as
unsaved
when the script has unsaved changes, or
Saved
after a successful save. After a save that reports errors, it reads
Saved with <number> error(s)
. If a save fails, it displays the reason.
RevertDiscards your unsaved changes and restores the last saved version of the script. Available only for a saved script with unsaved changes.
Save As…Saves the script under a new name. Opens the Save script as dialog.
SaveSaves your changes to the script. Available only for a saved script with unsaved changes.

Save script as dialog

The Save script as dialog contains the following controls.

Control

Description

Script nameSets the name of the script. If a script with that name already exists, the dialog displays an error and you can't save.
CancelCloses the dialog without saving. You can also press Esc.
SaveSaves the script under the new name. You can also press Enter.

Additional resources