How do I access a variable from a different node's script?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By BuenosNachos

I need to know how to access a variable from another node in the scene, I have a player object that is a KinematicBody2D and a coin that is an Area2D. The coin is trying to access the variable score from the player’s script. Any help would be greatly appreciated, thanks in advance!

:bust_in_silhouette: Reply From: usurun

You just have to find the node and then use node.variable = value

You can also use “autoload” in the autoload tab in project settings

This can let you have scene running outside the current scene, so you can find it with

onready var search_node = $"/root/scene"

This is usefull, because you can find it even if you change to another scene.