attach_script
Attach an existing GDScript file to a node in a Godot scene, automatically saving and replacing any previous 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. Errors if scriptPath does not exist or nodePath is not found. Returns { success, nodePath, scriptPath }.
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") |