When you click below the object with the mouse, it still disappears!

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

There was a problem when working with a mini-game for phones. My idea is that when you click on an object with the mouse, it should disappear, but for me it only disappears when you click under it or on the side! What to do, please help!
IMAGE: image.PNG - Google Drive
Code:
`extends StaticBody2D

var pos = Vector2()
var mouse_over = false

func _ready():
pos.x = global_position.x
pos.y = global_position.y

func _input(event):

var pos_mouse = get_global_mouse_position()

if Input.is_action_pressed("clicker"):
	if get_viewport_rect().has_point((to_local(pos_mouse))):
		queue_free()
		global.flag = true`