so I made the code in the coin scene where ur characters collect all coins all 15 coins(maxcoins) it's gonna change the scene but it didn't work until i change the max coin to 1 it work but more than that it doesn't work
enter code here
extends Area2D
var collectedCoins = 0
var maxCoins = 2
func onbodyentered(body):
if body.name == "Player":
var tween = gettree().createtween()
var tween1 = gettree().createtween()
tween.tweenproperty(self, "position", position - Vector2(0, 35), 0.35)
tween1.tweenproperty(self, "modulate:a", 0, 0.3)
tween.tweencallback(queue_free)
collectedCoins += 1
print("Collected coins:", collectedCoins)
if collectedCoins >= maxCoins:
print("Reached maximum coins!")
get_tree().change_scene_to_file("res://main.tscn")