For my enemy code:
var maxhp= 10
var currenthp
currenthp= maxhp
Func Onhit(damage):
currenthp -=damage
If currenthp <=0
dead()
Else:
$AnimationSprite.play("hurt")
My player code:
var damage
Func Area2dbodyentered(body):
If body.isingroup("enemies")
body.Onhit(damage)
Func physicsprocess(delta):
If event.Input.isactionjust_pressed("melee"):
damage=5
$Animationplayer.play("attack")
The end result is that the first damage is only counted like 10-5 = 5 and the current_hp will always stay on 5