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):

func Lazer_Checking():
if Triped and !Has_been_Triped:
$Sprite.texture = Yellow_Lazer
Triped = false
Has_been_Triped = true
if Triped and Has_been_Triped:
$Sprite.texture = Red_Lazer
Lazer_detected = true
$Sprite.texture = Green_Lazer

func _on_Lazer_body_entered(body):
if “Player” in

func _on_Timer_timeout():
Triped = true

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()