How to make a trigger for spikes

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

I’m trying to make spikes that every time that you touch them they take away some points but right now it just does it really fast and that’s not what I want

Heres my code:
extends Area2D

func _physics_process(delta):
var boide = get_overlapping_bodies()
for body in boide:
if body.name == “Player”:
global.Coins -= global.Take_away
if global.Coins < 0:
get_tree().change_scene(“res://Scenes/Death screen.tscn”)

:bust_in_silhouette: Reply From: XxcringekidxX

I Figured it out:
extends Area2D

onready var timer = get_node(“Timer”)

func _on_Area2D_body_entered(body):
if body.name == “Player”:
timer.start()
pass # Replace with function body.

func _on_Timer_timeout():
global.Coins -= global.Take_away
pass