Godot Version
4.3
Question
I’m new to Godot and for a couple days I’ve been trying to figure out why my script suddenly stopped working, it’s connected to my base white circle node(I have no idea what it’s called) and it worked fine before, I tried to change the script but even stuff that I know work don’t and I’m not even sure if the problem has something to do with the script so I didn’t put it in Programming Help.
Here’s the script:
extends Node
var enemy_health = 100
func keyattack(event):
if event.is_action_pressed("take_damage"):
enemy_health -= 10
$EnemyHP.text = str(enemy_health)
print(enemy_health)
if enemy_health <= 0:
enemy_health = 0
$EnemyHP.text = "Dead"
$EnemyHP.modulate = Color.RED
elif enemy_health == 100:
$EnemyHP.modulate = Color.WEB_GREEN
So the goal for the script is to lower a number in a text in a Label called EnemyHP it starts at 100 and once it gets to 0 it turns red, but it’s not working and I don’t know why.
I need help.