attach_script
Attach an existing GDScript file to a node in a scene, replacing any previously attached script. Works after writing and validating the script. Saves automatically.
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 |
|---|---|---|---|
| nodePath | Yes | Node path from scene root (e.g. "root/Player") | |
| scenePath | Yes | Scene file path relative to the project | |
| scriptPath | Yes | Path to the GDScript file relative to the project (e.g. "scripts/player.gd") | |
| projectPath | Yes | Path to the Godot project directory |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| success | No | ||
| nodePath | No | ||
| scriptPath | No |