after get_tree.reload_current_scene player cannot move and fps drops to 22

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

Hi im new and i have a global autoload script which has a variable called player health
and in my enemy script when the player collides with it -= the player_health var in the global script.

and in the global script it has process function which has a if player_health <= 0:

so the issue is when the health reaches 0 it reloads the scene but the player and enemies cant move and the fps drops to 22
Also theres no errors in the console

Heres the code

extends Node

var crosshair = load('res://assets/cursor.png')
var player_health = 100

func save():

func load_game():

func _ready():

func _process(delta):

if player_health <= 0:

plz help,

:bust_in_silhouette: Reply From: Lopy

The scene is reloaded every tic, because player_health stays negative. If the player or some other non-autoload Node was trying to set the value back to 100, it likely failed because it was replaced before it’s _ready() could be called.