It is giving me an error for get_root. HELP!

Add the @onready to your player variable declaration.

@onready var player = get_tree().get_root().get_node(“/root/Game/Player”)

The error you got was because you tried to call get_tree() before the node entered the scene tree, so it returned null. Then, you called your get_root() on a null value - hence the error message. The @onready ensures this piece of code is ran only after the node entered the scene tree and is ready.

1 Like