Get_tree().get_current_scene().name not working

Godot Version



When I tried to use the function get_tree().get_current_scene().name it returned @Node2D@2. I had this on a node with autoload that would check if the scene name was Menu to do certain things if the player is on the menu. I had something like this in another game, that was made in 4.0, and it worked. I don’t know why it doesn’t work here, what am I doing wrong?

Most likely you have two instances of this scene competing for its name.
This is common when the same autoloaded node is also run as an instantiated node.
Godot needs to distinguish between these and manipulates the name.
You can specifically set the name property to overcome this.
name = "Menu"
But I would sincerely re-look at a design which calls an autoload and an instance of the same.

I fixed it now, I think my problem was that the autoload scene had Menu as the path, then I changed it to MenuScene and it worked.