How do I tick down a counter when a object is overlapping

Godot Version

v4.2.1.stable.official

Question

I’m making a multiplayer game where you have to have the ball overlap the goal until a timer hits zero. I’m working on one goal at the moment and here is my code for the goal:

extends Area2D

var time_left_for_red_goal = 1000
var timer_on = false

func _process(delta):
score_counter()
time_left()
print(time_left_for_red_goal)

func score_counter():
if overlaps_area($“…/BALL”):
timer_on = true
print(time_left_for_red_goal)
if not overlaps_area($“…/BALL”):
timer_on = false

func time_left():
if timer_on == true:
time_left_for_red_goal = time_left_for_red_goal - 1

it’s been a while since I touched this project and Godot in general. Can you help me out? Thanks!

Normally you should use the area_entered and area_exited signals instead of using overlaps_area.

But, the code you have there doesn’t seem to have any obvious problems.

What issues are you running into?