Can't get line2D to stop updating

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

I am trying to add a whiteboard feature to my game where the player can draw the start and end point of a line, and the line is then left drawn on the screen. Drawing the line to the mouse works fine, however the line doesn’t stop drawing when I try to make it.

extends Area2D

var stopped
var zoom
var start_pos = Vector2(0, 0)
var rng = RandomNumberGenerator.new()
var id = 28

func _ready():
	rng.randomize()
	zoom = 4
	stopped = false
	id = rng.randi_range(1, 10)

func stop():
	print("stop")
	stopped = true
	print(stopped)

func start_pos(val):
	start_pos = val


func _process(delta):
	zoom = get_parent().get_zoom()
	$DrawLine.width = 1 * zoom
	get_node("LineEnd").scale = Vector2(0.2, 0.2) * zoom
	get_node("LineStart").scale = Vector2(0.2, 0.2) * zoom
	if stopped == false:
		$DrawLine.remove_point(1)
		$DrawLine.add_point(get_global_mouse_position(), 1)

The stop function is called when clicking a second time, and stop is printed, then true, however the line continues to update. Even more weirdly, replacing the stop function code with just queue free() doesn’t do anything. I have also checked in the remote tab when running, and with the nodes id, and no aditional clone lines are being created.

the node setup is this:

-DrawnLine (the area2D)
    -DrawLine (the line2D)

and the code to instance and stop the line in the main scene is this:

func _unhandled_input(event):
if event.is_action_pressed("click") and drawing == true and placed == false:
	var l = line.instance()
	l.start_pos(get_global_mouse_position())
	add_child(l)
	placed = true
elif event.is_action_pressed("click") and drawing == true and placed == true:
	l.stop()
	drawing = false

I’ve been stuck on this for ages and feel like I’m going crazy, any help would be very appreciated!