Script / Attach To Node
script-attach-to-nodeAttach C# or GDScript files to a Godot scene node using a node reference and res:// script path, or clear the node's script by passing an empty path.
Instructions
Attach a script (C# '.cs' or GDScript '.gd') to a Node in the currently edited Godot scene — the Godot analog of adding a MonoBehaviour to a GameObject. Identify the target with 'nodeRef' (instanceId preferred, else scene-tree path) and the script with 'scriptPath' (a res:// script file that must exist). Pass an empty/whitespace/null 'scriptPath' to DETACH (clear) the node's script. The script resource is loaded and set via Node.SetScript; the scene is marked unsaved (persist with rql-mutate 'editor | call SaveScene()'). Returns the script's structured ScriptInfo on attach, or an identity record with a 'detached' status on clear.
Argument types — give these arguments as RQL values (as in rql-mutate): {key: value, …}, [a, b], "text", 1.5, true, ref("Node3D#12") from a query result, godot.find("Name"); leave out keys you do not need: NodeRef — a node: ref("Node3D#12") from a query, godot.find("Name"), an instance id, or its path below the scene root as text ("Level/Player")
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nodeRef | Yes | Reference to the target Node (instanceId preferred, else scene-tree path). RQL: NodeRef | |
| scriptPath | No | res:// path of the script to attach, ending in '.cs' or '.gd'. Pass empty/whitespace/null to DETACH the node's current script. |