current scene name

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jospic
:warning: Old Version Published before Godot 3 was released.

is there a way to get the current scene name?

:bust_in_silhouette: Reply From: Gokudomatic2

is there any reason that calling this would return null instance? i mean there’s always a scene… yet that’s what im getting.

var context = get_tree().get_current_scene().get_name()

trumpetfish1 | 2018-04-28 03:38

If your node is not in the tree (not a child of anything), then get_tree will be null and the expression will throw a NullRef error

jarlowrey | 2019-08-07 23:38

Thank you for your comment! But when I try it it doesn’t give me the name of the scene but the name of the node…

jobieadobe | 2022-03-13 02:59

you can just use .name to get the name of the node


milkteafloat | 2023-05-27 16:16