Instantiated instance does not have script

Godot Version



I created a scene as PackedScene and loaded it from a script.
The scene Arrow.tscn has a script on the root, but the instantiated object(arrow) does not have that script.

Here is a part of my codes.


arrow_scene = preload("res://Scenes/Arrow.tscn")

# arrow's class is Node2D and I want Arrow class as a result
var arrow = arrow_scene.instantiate()

extends Node2D

class_name Arrow

var speed
var aim

func _init(given_tag):
	speed = 50

You can’t use the constructor _init()with required parameters because instantiate() will fail then. It’s explained in the Object._init() documentation.


Oh, you’re right!
It works after I remove _init().
Thank you!