How do i fix this bug in my game

Godot Version

4.7.1

Question

I made a points system and i made a coin func _on_body_entered(body: Node2D) → void:
var game_manager = %Game_Manager
game_manager._points()
queue_free() that code calls func _points():
stringnum += 1
queue_free()
string = string + str(stringnum)
$“../CharacterBody2D/Camera2D/Label”.text = string but and it works the first time but the second coin i collect doesnt work it just gives me the error Attempt to call function ‘_points’ in base ‘null instance’ on a null instance.

Please check Posting guidelines in #Help channel.

From the code you pasted there’s a queue_free() inside _points(), and _points() lives on your Game_Manager. So collecting the first coin frees the Game_Manager itself. That’s why the second coin gets “null instance”, the manager is literally gone.

The queue_free() belongs to the coin, not the manager. Delete the one inside _points() and keep the one in the coin’s _on_body_entered after calling the manager:

func _on_body_entered(body: Node2D) -> void:
	var game_manager = %Game_Manager
	game_manager._points()
	queue_free()

And in Game_Manager, _points() only does the score:

func _points():
	stringnum += 1
	string = str(stringnum)
	$"../CharacterBody2D/Camera2D/Label".text = string

I also changed string = string + str(stringnum) to just str(stringnum), your version would build “12” then “123” instead of showing 1, 2, 3.