Area2d Wont change var on body entered

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

please help
queue_free does work but the var does not change when kinimaticbody2d entered

extends Area2D

var score = 0

func _on_Bug_body_entered(body):
score += 1
queue_free()

extends Label

func _process(delta):
self.text = str(Bug.score)

Try this:

extends Area2D

func onBugbodyentered(body):
    body.score += 1
    queue_free()

timothybrentwood | 2021-12-05 19:45

:bust_in_silhouette: Reply From: Inces

What is supposed to happen in this project ?
Bug earns its own score on collision and immadietely dies. So every Bug in your game has 1 score in total lifetime :). Is Bug main player or enemy ? You mixed something up, You propably want one global score, not a lot of locals ?