Here's the code.
extends Node2D
export var value = 1
var coin_get : bool
func _ready():
print(get_owner())
print(get_owner().coins_collected)
get_node("Area2D").connect("body_entered", self, "_collect_coin")
func _collect_coin(body):
print(body)
$CoinSound.play()
if str(body) == "Player:[KinematicBody2D:1294]":
get_owner().coins_collected += value
print(get_owner().coins_collected)
queue_free()
All of the code under the collectcoin function runs except for the coin sound. I've looked online and am pretty sure that that's how you would play sound. If you need anything else I'm happy to give it. Thanks.