How to stop a Timer as it is counting

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

So I am trying to make a lazer that when the player walks through it it will activate something but if it dashes it will just be on the middle of activating it and will stop. So I use a Timer, which is a child of an area, 0.5 seconds to make it on the middle of activating making it color yellow and 0.5 seconds a again to make it activate making it color red but when you exit the area2d it will be color green but it will still turn red activating something I need a way to stop the timer.

If you need its code here (also its activating spikes which will insta kill you):
const Green_Lazer = preload(“res://Assests/Tile Set/Green Lazer.png.png”)
const Yellow_Lazer = preload(“res://Assests/Tile Set/Yellow Lazer.png.png”)
const Red_Lazer = preload(“res://Assests/Tile Set/Red Lazer.png.png”)

var Triped = false
var Has_been_Triped = false
var Lazer_detected = false

signal Open_spike

func _physics_process(delta):
Lazer_Checking()

func Lazer_Checking():
if Triped and !Has_been_Triped:
$Sprite.texture = Yellow_Lazer
Triped = false
$Timer.start(0.05)
Has_been_Triped = true
if Triped and Has_been_Triped:
$Sprite.texture = Red_Lazer
emit_signal(“Open_spike”)
Lazer_detected = true
else:
$Sprite.texture = Green_Lazer

func _on_Lazer_body_entered(body):
if “Player” in body.name:
#emit_signal(“Open_spike”)
print(“start”)
$Timer.start(0.05)

func _on_Timer_timeout():
Triped = true
print(“end”)

func _on_Lazer_body_exited(body):
if !Lazer_detected:
$Sprite.texture = Green_Lazer

:bust_in_silhouette: Reply From: Fgico

if I’m not wrong you should be able to call stop() on any timer,
in your case you could try $Timer.stop()