Don't copy the value
In the code you are taking a copy of the value ammo
and store it in the variable ammod
:
extends Label
var NODE = load("Marine.tscn")
var ammo = NODE.instance()
var ammod = ammo.ammodisplay
Then you display the copy, which does not get updated.
func _process(delta):
text = (str(ammod))
Read the value again instead:
func _process(delta):
text = (str(ammo.ammodisplay))
Getting the correct node
Besides, it is unclear from the example if you actually want to instantiate a new instance with this script, or you want to access one you have in the scene tree. For example, your declarations could look like this:
extends Label
onready var ammo = $Marine;
Which assumes you have a node Marine
as child of the Label
in the scene tree. The type of ammo
will be that of the node Marine
. The code above is roughly equivalent to (except the version below has worst IDE integration, and worse typing information):
extends Label
onready var ammo = get_node("Marine");
The type of ammo
will be Node
.
In case you are not familiar with onready
, let me tell you that the code above is roughly equivalent to (except the version below has typing information lost):
extends Label
var ammo = null;
func _ready():
ammo = get_node("Marine");
The type of ammo
will be Variant
.
It is important to get the node in ready or afterwards because initialization of the node happens before it is added to the scene tree (and thus can't get nodes from it).
Chances are that Marine
should not be a child of the Label
. For that situation I suggest to export a node path.
By exporting a node path you can specify in the editor when the node you want to access. For example:
extends Label
export(NodePath) var ammo_path;
onready var ammo = get_node(ammo_path);
Then in the inspector panel you will see a new property "Ammo Path" (Godot auto capitalizes the name) where you can specify where in the scene tree the node you want to access is.