EDIT: wow the formatting really got messed up here X_X but im not sure what i did wrong. ill try to fix later, atm need to step away form compueter
Hi all! Sorry to post again asking for help...
I hit a problem I've been googling about but can't quite find the answer to.
I've been trying to work along with the GUI on my game, referencing this tutorial (link)
For some reason I"m getting an error saying that my bar is null...
it reads : Invalid set index 'max_value' (on base: 'null_instance' )with value type 'int'
Here is the script I have, through the ready function
extends Control
onready var bar = $HealthBar
onready var tween = $Tween
onready var pause_screen = $PauseScreen
#this is needed for PAUSE SCREEN which INHERITS from this script
signal resume_game_signal
# Called when the node enters the scene tree for the first time.
func _ready():
var player = find_node_by_name(get_tree().get_root(), "AnimatedPlayer")
#we DID findhte plaeyr i checked
# if player != null:
# print("Hi we foudn the player! :D")
# else:
# print ("No player I CRY D:")
var players_max_health = player.maxHealth
if bar != null:
print (" we have a health bar")
else:
print ("Health bar is null")
bar.max_value = players_max_health
update_health(player.currentHealth)
#player doesn't need to see this right hwen the load
turn_off_pause_menu()
I've tried looking around more about 'onready' vars, but it seems like that the children should be called before the thing is considered ready? If im reading right.
So I don't know quite wehre I went wrong
I get the print statment that i put in, my health bar is null. and i tested before then, my player was found (not null)
the error seems to crop up on the line reading
bar.max_value = players_max_health
thanks for anyone who can help. .sorry if the codes um. a bit messy. I've been working on that ;-;