It looks like you have two scenes:
Mainmenu. If only one of those is active in the Scene Tree, the other won't be accessible through the method you are using. I'm unsure how you go about the scene transitions (if you are transitioning between them), but if you call
get_tree().change_scene() and pass it the
World1 Packed Scene (*.tscn, *.scn files), then the current scene,
Mainmenu will be unloaded and removed from the Scene Tree, being replaced with
World1. This would be why
null -- the node named
Mainmenu doesn't exist.
One way to pass the
play node from
World1 is to use a global singleton -- an autoload script that is always accessible during runtime.
You would need to create a new script and call it whatever you would like; I will use "
global" for simplicity. Then, add the script as an autoload.
If you don't know how to add a singleton, see below:
Click "Project" in the top-left, then "Project Settings...". In the pop-up, find the tab at the top labeled "Autoload", finally clicking the folder button; navigate to the script file, then click the "Add" button at the far-right. Do note, Godot will most likely replace any underscores with spaces and capitalize all the words.
In the autoload script, make a variable called
player. This is where you will transfer the node
Skip here if you already know how to add a singleton.
In the script for the
player node in
onready var m = get_node("/Mainmenu/Mainmenu/Camera2D/play")
onready var m = Globals.player
Globals is just the name I am using; you can use whatever name you set for your autoload.)
(I am looking at this after writing it and realizing it might be a tad bit confusing. I hope this is easy enough for you to understand, and hopefully it helps.)