0

I got this error in one of my gdscript scripts in a Godot project: "Too many arguments for "get_script()" call. Expected at most 0." For this line of code:

onready var coinscript = get_script("res://path/script.gd") 

I have no idea why this error is there. Anyone do?

Tibbe
  • 1
  • 1

1 Answers1

4

The get_script takes no arguments and returns the Script attached to the current object. That is, the script you are writing. Which can be useful, for example, for meta-programming.


However, it appears you want an script given its path. Thus, you probably want to use load instead:

onready var coinscript = load("res://path/script.gd") 

See also preload, ResourceLoader.load, Loading vs Preloading and Background Loading.

Theraot
  • 31,890
  • 5
  • 57
  • 86