Invalid argument error after crash

Godot v4.3
Replace this line with your Godot version

I keep getting crashed, and get the error Missign Node on one of my scenes. I’ve just fixed this by remaking the scene from the other scenes it contained, as they are still working.

The last time I had this happen I suddenly got a new Error in the script for my NPC. The error says: Invalid assignment of property or key ‘interact’ with value of ‘Callable’ on a base object of type ‘null instance’.

I don’t know why this suddenly became an error, as it was working fine before the crash. I am completely new to this, so would appreciate any help.

This is my code for reference.

extends Node2D

var resource = load("res://dialogue_resource")
var talk = 0
var dialogs = 0

@onready var interaction_area: InteractionArea = $InteractionArea

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	interaction_area.interact = Callable(self, "_on_interact")


func action() -> void:
	pass

func _on_interact():
	if talk == 0 and dialogs == 0:
		dialogs = 1
		print(dialogs)
		DialogueManager.show_example_dialogue_balloon(load("res://dialogs/Test.dialogue"), "start")
		DialogueManager.dialogue_ended
		


func _on_canvas_layer_writing() -> void:
	print("hei")
	talk = 1


func _on_canvas_layer_not_writing() -> void:
	talk = 0

The null instance means that your interaction_area is null.

So this line:

@onready var interaction_area: InteractionArea = $InteractionArea

is not getting the correct node.
So the name is incorrect or this script is an autoload and not the scene itself

Thank you! The problem is that I made the script an autoload right before Godot crashed. Is there a different way I can get the node that will work?

If that node is part of a scene then you should autoload the scene .tscn instead of the script .gd.

Like @gertkeno said, make the scene an autoload instead of the script.