Function GodotObject.setScript

Assigns a script to the object. Each object can have a single script assigned to it, which are used to extend its functionality. If the object already had a script, the previous script instance will be freed and its variables and state will be lost. The new script's init method will be called.

void setScript (
  Reference script
) nothrow @nogc;