PackedScene Nonexistent function in base Node2D

Godot Version

4.2.2

Question

Hi all, I am trying to use a function in a packedScene I’ve instantiated, But I keep getting the error the function ‘set_direction’ in base node2D doesn’t exist, any ideas?

Heres the code for the thing I’m trying to get working

		var bullet = bullet_scene.instantiate()
		bullet.position = global_position + bullet_offset
		get_tree().root.add_child(bullet)
		print("Bullet instantiated:", bullet)
		bullet.set_direction(target.global_position, bullet_speed)

and this is the function in the bullet.tscn I have preloaded

func set_directions(target_position: Vector2, bullet_speed: float):
	direction = (target_position - global_position).normalized()
	speed = bullet_speed
	rotation = direction.angle()

There’s a typo.

bullet.set_direction(target.global_position, bullet_speed)direction

func set_directions(target_position: Vector2, bullet_speed: float):directions

I have changed that and I am still getting the error, also tried to preload the bullet.tscn which didn’t seem to fix it and I saved the changes too

If your bullet scene has a script with a custom class name like:

class_name Bullet extends Node2D

you need to apply a cast in this line:

bullet = bullet_scene.instantiate() as Bullet