attach_script
Attach a GDScript file to a node in a Godot scene, replacing any existing script and saving automatically. Use after writing and validating the script.
Instructions
Attach an existing GDScript file to a node in a scene. Use after writing the script with the standard file tools and validating it via the validate tool. Replaces any previously attached script. Saves automatically. Returns: success with the resolved nodePath and scriptPath that were attached. Errors if scriptPath does not exist or nodePath is not found.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | Yes | Path to the Godot project directory | |
| scenePath | Yes | Scene file path relative to the project | |
| nodePath | Yes | Node path from scene root (e.g. "root/Player") | |
| scriptPath | Yes | Path to the GDScript file relative to the project (e.g. "scripts/player.gd") |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| success | No | ||
| nodePath | No | ||
| scriptPath | No |