My Gamecrashes the moment the enemy hp drop > 75% godot 4

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Dev_Avishka
extends CharacterBody3D

signal ai_done
@onready var nav_agent = $NavigationAgent3D
var SPEED = 3.0
@onready var hp_bar = $ProgressBar
var hp = 10000
func _physics_process(delta):
	var current_loc = global_transform.origin
	var next_loc = nav_agent.get_next_location()
	var new_vel = (next_loc-current_loc).normalized()*SPEED
	velocity = new_vel 

func _process(delta):
	hp_bar.value = hp
	if hp == 0:

func  update_target_loc(target_loc):

func faceDirection(direction : Vector3):
	look_at(Vector3(direction.x, global_position.y, direction.z), Vector3.UP)
func _on_player_shotduo():
	hp -= 5 # Replace with function body.

func _on_player_stduo_2():
	hp -= 200 # Replace with function body.

Do you get any error messages? I’m not sure the problem is in this code either.

Cam | 2023-02-04 06:03

No suddenly when the enemy reaches below 75% the game goes white and I have to stop the game from running but when I remove this script it works perfectly

Dev_Avishka | 2023-02-06 05:21