I want to get the Player's health in other nodes after all nodes are done

I think because I try to get the Player’s health in the _ready function of other nodes the player might not be completed yet.

Can someone explain to me how to fix it?, thanks

_ready() runs from the bottom of each node branch to the top, and then up the tree. I think of it as “Ready is Reverse”. So if your player is top-left (higher in the tree) then it gets _ready run late.

_init() runs the opposite way.

Still, please give us a bit more info to be able to understand your problem.

I don’t really know what information you’ll need, so there are 3 things, 1 is the global script that contains the pointer to the world scene and the second is I have a player node in the world scene and the UI is also in the world scene that shows the player’s health, I want to get the player’s health through the world pointer in the Global script in the ready function of the UI

I can’t read your mind. Try to better describe by means of ascii art or a screenshot and include some code. Go a little out of your way.

I suspect you will probably find signals will help you in this situation. Also maybe an autoload singleton. But I am guessing.

In my World scene, there’re 2 nodes: Player and GamestatsUI, I want to get the health variable in the Player node inside the func _ready() of the GamestatsUI, how can i do that?

Why do you need the health in the stats ready?

Try move that logic around, perhaps put a call for player.health in the process() func of the stats node.

Or make a signal in player and emit it when the health changes. Have stats connect to that. This will give stats the opportunity to do what it needs when player is actually ready for it.

But the max value of the health should be get at the start, i want to show the full health of player when the game starts

Do that in an export var in the player

@export var health = 22 # so you can vary this in the inspector
Or, a global var (just without export)
var health = 22 # if you don’t need that.

Then it’s available faster than stuff in _ready.