I'm trying to make sure that my 'Hearts' counter is able to update, however when I try to load the game all I get is this error
Invalid get index 'self' (on base: 'Node (stats.gd)').
Here is my code and thank you in advance for your help!
extends Control
@onready var label = $Label
var hearts = 4:
get:
return hearts
set(value):
hearts = clamp(value, 0, max_hearts)
var max_hearts = 4:
get:
return max_hearts
set(value):
max_hearts = max(value, 1)
func _ready():
self.max_hearts = PlayerStats.max_health
self.hearts = PlayerStats.health
self.PlayerStats.connect("health_changed","set_hearts")