Try not reusing variable names, and changing it to this:
extends KinematicBody2D
onready var BULLET = preload("res://Bullet.tscn")
func _process(delta):
if Input.is_action_just_pressed("ui_right"):
var new_bullet = BULLET.instance()
new_bullet.transform = transform
get_node("/root/World").add_child(new_bullet)
connect_to_bullet(new_bullet) #Here I conect the new Bullet
func connect_to_bullet(bullet_node): #Here is the function as you sad
bullet_node.connect("Hit",self,"on_BULLET_Hit")
func _on_BULLET_Hit(): #And here is the conection from the Bullet.
print("Hello")
I swapped out the reused variable names, and put in the correct variable referencing the bullet when the connect function is called. I think this should work.
EDIT: I just realized as well you have the hit signal code in the _ready()
section of your bullet. This will cause the bullet to print("Hello") when it's spawned, not when it hits something. Although you might just being doing that for testing.
EDIT2: Because you have the bullet emitting the signal on its _ready()
, it'll end up emitting its signal before the player has had a chance to connect the two, as `_ready() is called after the node's been added to the scene tree