How to make the enemy shoot after export?

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

When I export a game for windows, opponents do not shoot. When I start the game in the engine itself, everything works fine. How can this be fixed?

Enemy shooting code:

	var ttim_tim = delta
	ttim += ttim_tim
	if $RayCast2D3.is_colliding():
		var coll = $RayCast2D3.get_collider()
		if coll.name == "Player":
			$AnimatedSprite.play("shoot")
			velocity.x = 0
			var bul = bullet.instance(1)
			var bul_e = shoot_effect.instance()
			if sign($Position2D2.position.x) == 1:
				bul.set_bullet_direction(1)
				bul_e.set_shoot_effect_direction(1)
				bul.position = $Position2D2.global_position
				bul_e.position = $Position2D2.global_position
			else:
				bul.set_bullet_direction(-1)
				bul_e.set_shoot_effect_direction(-1)
				
				bul.position = ($Position2D2.global_position) + Vector2(-10, 0)
				bul_e.position = ($Position2D2.global_position) + Vector2(-10, 0)
				
			if ttim > 0.3:
				get_node("../").add_child(bul)
				get_node("../").add_child(bul_e)
				$AnimatedSprite.play("shoot")
				$shoot.play()
				ttim = 0

ERROR: Edit state is only for editors, does not work without tools compiled.
At: scene/resources/packed_scene.cpp:1692:instance() - Condition “p_edit_state != GEN_EDIT_STATE_DISABLED” is true. Returned: __null
SCRIPT ERROR: Attempt to call function ‘set_bullet_direction’ in base ‘null instance’ on a null instance.
At: :42:_physics_process() - Attempt to call function ‘set_bullet_direction’ in base ‘null instance’ on a null instance.

Zidd | 2020-06-11 08:26